[uClinux-dev] msh: detect if a file exists
Michael Schnell
mschnell at lumino.de
Tue Jun 10 08:30:59 EDT 2008
> I did "man sh", "man test" or "man [" - all of them (on Ubuntu) have
> -e but not -a for file testing. :-)
>
I did man bash on Suse 10.3
> There's no msh documentation as far as I know, but it's basically a
> standardish old-style Bourne shell with some bugs, and notably no
> user-defined functions (which are a modern feature anyway). So most
> "sh" documentation applies to msh.
>
> Bash is full of extensions to the Bourne shell, so a lot of what you
> see in the Bash documentation does not apply to msh.
>
I'm aware of that.
> On some Linuxes "man sh" gives you Bash documentation; on others, it
> gives you Ash documentation which is closer to old-style Bourne shell.
>
I did not know that there in fact is a "sh". I thought sh would be
always used as a symlink to the best shell on the system so that this is
used. On my Suse sh is a symlink to bash, on my uCLinux by default it's
a symlink to sash,.
But "man sh" in fact shows an appropriate documentation that seems to be
usable for msh (but here I don't fined the -e in the "man sh" file.
Neither in "man [" :( ).
> Having said all that, in your problem it's not the msh command at all.
> If you study Bourne shell, you'll see the command is "if COMMAND; then
> ...".
>
> So you are running the command "[ -e file ]". That means you need the
> documentation for the "[" command - there really is one :-)
>
OK, but without documentation it's really hard "man [" see above and "[
--help" does nothing useful " in my system.
> It's the same as the "test" command. It happens to be built in to
> some shells, including Bash, but not all.
Ahhhh ! (Though [ additionally seems to search for a "]" . )
"test --help" does nothing, but "man test" provides the information you
gave me; no -a, but -e is described :).
Thanks again !
-Michael
More information about the uClinux-dev
mailing list