Sponsored Content
Full Discussion: Cd
Top Forums UNIX for Dummies Questions & Answers Cd Post 7977 by Perderabo on Thursday 4th of October 2001 09:37:55 AM
Old 10-04-2001
Quote:
Originally posted by Neo

/usr/bin/cd /tmp; rm -rf *

This would appear, if I'm not mistaken, to spawn a child process that would remove all the files in the /tmp directory.
Sorry, that won't work. I sure hope nobody tried that. Try this instead:
/usr/bin/cd /tmp; /usr/bin/pwd

Even when commands are stacked with semicolons, we still have a shell processing the command line. And it still must spawn a child, let the child run /usr/bin/cd, wait for the child to die, spawn a second child, which will run /usr/bin/pwd.

Quote:
Originally posted by devnul
Well, I just wanted to add that on Solaris /usr/bin/cd is a two-line shell script....

cmd=`basename $0`
$cmd "$@"
That's it.. Nothing more...
Actually there are some comments as well which date it Feb 6, 1995 and it has a 1995 copyright. This gives us some idea of when it appeared. 1995 does sound about right.

HP's version is also a simple script:
cd $@
exit $?

HP doesn't show a date, but it does have a comment showing that it is revision 72.2. It's hard to imagine 72 revisions on a script like this, but I guess it's not a job you assign to your best programmer.

The format of Sun's script shows that it's using its name to find the command. I got a list of all the files in /usr/bin linked to the same file. The list is alias, bg, cd, command, fc, fg, getopts, hash, jobs, kill, read, test, type, ulimit, umask, unalias, and wait. Only kill and test really make any sense. Oh well.
 
BZEXE(1)						      General Commands Manual							  BZEXE(1)

NAME
bzexe - compress executable files in place SYNOPSIS
bzexe [ name ... ] DESCRIPTION
The bzexe utility allows you to compress executables in place and have them automatically uncompress and execute when you run them (at a penalty in performance). For example if you execute ``bzexe /bin/cat'' it will create the following two files: -r-xr-xr-x 1 root bin 9644 Feb 11 11:16 /bin/cat -r-xr-xr-x 1 bin bin 24576 Nov 23 13:21 /bin/cat~ /bin/cat~ is the original file and /bin/cat is the self-uncompressing executable file. You can remove /bin/cat~ once you are sure that /bin/cat works properly. This utility is most useful on systems with very small disks. OPTIONS
-d Decompress the given executables instead of compressing them. SEE ALSO
bzip2(1), znew(1), zmore(1), zcmp(1), zforce(1) CAVEATS
The compressed executable is a shell script. This may create some security holes. In particular, the compressed executable relies on the PATH environment variable to find gzip and some other utilities (tail, chmod, ln, sleep). BUGS
bzexe attempts to retain the original file attributes on the compressed executable, but you may have to fix them manually in some cases, using chmod or chown. BZEXE(1)
All times are GMT -4. The time now is 06:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy