Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Using Zsh on a embedded system to configure GPIOs



On Nov 29, 10:10am, meino.cramer@xxxxxx wrote:
}
} To overwrite files I need to use ">!" instead of ">".
} 
} Is there any way to automate this feature NOT to hit on my fingers,
} if I want to write to files below /sys, /proc,, /dev...or
} (better) to recognize, if such a file is a virtual one?

I confess to being confused by the phrase "to hit on my fingers" ...
but I think I can answer anyway.

The HIST_ALLOW_CLOBBER option replaces ">" with ">|" in the history,
so that if you forget to use the clobbering form all you need to do
is recall the previous command with "!!" or the line editor.  Does
that help?

NO_CLOBBER already behaves differently for non-regular files, so that
you can do things like "print foo > /dev/pts/3" without having to use
">|" (though that won't work for /dev/tty for a different reason).

So if there is some way to identify a "virtual file" e.g. with stat(),
that could potentially also be handled.  However, I think virtual files
masquerade pretty thoroughly as real ones except for the fact that they
appear to have size 0 yet contents can still be read.

I suppose that, since the point of NO_CLOBBER is to prevent destroying
existing file contents, redirection could be allowed to succeed for
existing zero-sized files, which would then work for virtual files.

However, that's not the way it works now, and zsh-workers would need to
have some discussion of whether that change is acceptable.



Messages sorted by: Reverse Date, Date, Thread, Author