[OpenIndiana-discuss] PATH=/usr/xpg4/bin /bin/ksh -c "rm -f"
James
list at xdrv.co.uk
Thu Jun 13 13:20:28 UTC 2019
Hello, please can someone help me understand this xpg4, ksh, rm oddity?
Normally: rm with no args complains and adding -f makes it accept no args.
$ rm
usage: rm [-fiRr] file ...
$ rm -f
$
On OpenSolaris [but not 10, 11.3] with /usr/xpg4/bin in the path it
behaves differently but only with /bin/ksh or /bin/sh (ksh93)
$ PATH=/usr/xpg4/bin /bin/ksh -c "rm -f"
Usage: rm [-cFdfirRuv] file ...
$ PATH=/usr/xpg4/bin /bin/sh -c "rm -f"
Usage: rm [-cFdfirRuv] file ...
$ PATH=/usr/xpg4/bin /bin/zsh -c "rm -f"
$ PATH=/usr/xpg4/bin /bin/bash -c "rm -f"
Without xpg4 in the path:
$ PATH=/usr/bin /bin/ksh -c "rm -f"
Calling rm directly does what I expect:
$ PATH=/usr/xpg4/bin /bin/ksh -c "/usr/xpg4/bin/rm -f"
$ PATH=/usr/xpg4/bin /bin/ksh -c "/bin/rm -f"
$ PATH="" /bin/ksh -c "PATH=/usr/xpg4/bin rm -f"
$ PATH=/usr/xpg4/bin /bin/ksh -c "alias rm"
rm: alias not found
$ PATH=/usr/xpg4/bin /bin/truss -f /bin/ksh -c "rm -f" |& grep rm
4436: lstat("/usr/xpg4/bin/rm", 0xFFFFFC7FFFDFDCE0) = 0
Usage: rm [-cFdfirRuv] file ...
$ PATH= /bin/truss -f /bin/ksh -c "PATH=/usr/xpg4/bin rm -f" |& grep rm
4439: execve("/usr/xpg4/bin/rm", 0x00AA80E0, 0x00AA8108) argc = 2
4439: resolvepath("/usr/xpg4/bin/rm", "/usr/xpg4/bin/rm", 1023) = 16
4439: stat64("/usr/xpg4/bin/rm", 0x0803E900) = 0
I can't see a built-in rm or alias in ksh and if it were I would expect
-f to have the same effect. The path must be making ksh act
differently. What am I not understanding here?
More information about the openindiana-discuss
mailing list