[uClinux-dev] msh: detect if a file exists
Jamie Lokier
jamie at shareable.org
Tue Jun 10 07:25:24 EDT 2008
Michael Schnell wrote:
> >You meant -e, and that does work with msh.
> >
> Thanks a lot, Jamie. That was the trick.
> (In the bash documentation -a and -e are equivalent, so I stopped
> reading when I found -a.)
>
> How did you know this ? Do you have an msh documentation ?
I did "man sh", "man test" or "man [" - all of them (on Ubuntu) have
-e but not -a for file testing. :-)
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.
On some Linuxes "man sh" gives you Bash documentation; on others, it
gives you Ash documentation which is closer to old-style Bourne shell.
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 :-)
It's the same as the "test" command. It happens to be built in to
some shells, including Bash, but not all.
-- Jamie
More information about the uClinux-dev
mailing list