weird sh(1) behaviour
Richard A. O'Keefe
ok at quintus.uucp
Wed Aug 3 09:37:25 AEST 1988
In article <163 at cstw01.UUCP> meulenbr at cst.UUCP () writes:
>I noticed a peculiarity in sh which causes me a lot of trouble.
>The commands:
> sh file
>and
> sh <file
>are NOT equivalent.
>If you do think so, create a file which contains the command
> rm core
It isn't the shell's fault. The sensitive command is 'rm'.
rm(1) will print an error message iff >>its<< standard input
is a terminal. To verify this, in a directory having no 'core' file, do
</dev/tty rm core # produces an error message
</dev/null rm core # is silent
If your script contains the line
</dev/tty rm core
then both "sh script" and "sh <script" will produce the error message.
This is known and intended behaviour of the BSD /bin/rm; it doesn't
happen under V.3. However, doing
</dev/null rm file...
is harmless in V.3
More information about the Comp.unix.wizards
mailing list