On Mon, Jun 17, 2019 at 11:15 AM James <[email protected]> wrote: > 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/truss -f /bin/ksh -c "rm -f" |& grep rm > 4436: lstat("/usr/xpg4/bin/rm", 0xFFFFFC7FFFDFDCE0) = 0 > Usage: rm [-cFdfirRuv] file ... > ... > 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? >
In ksh, /usr/xpg4/bin/rm is a builtin. % ksh builtin | grep /rm /bin/rmdir /usr/ast/bin/rm /usr/ast/bin/rmdir /usr/xpg4/bin/rm You can see this from your ouput above too: for one thing, that's the ksh builtin usage message; for another truss doesn't show an execve. You appear to be ending up in this code: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libcmd/common/rm.c#395 (And if you add '-u libcmd::' to your truss invocation you can see it calling the b_rm function there.) -- -Peter Tribble http://www.petertribble.co.uk/ - http://ptribble.blogspot.com/ _______________________________________________ openindiana-discuss mailing list [email protected] https://openindiana.org/mailman/listinfo/openindiana-discuss
