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.
 
INITSCRIPT(5)						Linux System Administrator's Manual					     INITSCRIPT(5)

NAME
initscript - script that executes inittab commands. SYNOPSIS
/bin/sh /etc/initscript id runlevels action process DESCRIPTION
When the shell script /etc/initscript is present, init will use it to execute the commands from inittab. This script can be used to set things like ulimit and umask default values for every process. EXAMPLES
This is a sample initscript, which might be installed on your system as /etc/initscript.sample. # # initscript Executed by init(8) for every program it # wants to spawn like this: # # /bin/sh /etc/initscript <id> <level> <action> <process> # # Set umask to safe level, and enable core dumps. umask 022 ulimit -c 2097151 PATH=/bin:/sbin:/usr/bin:/usr/sbin export PATH # Increase the hard filedescriptor limit for all processes # to 8192. The soft limit is still 1024, but any unpriviliged # process can increase it's soft limit up to the hardlimit # with "ulimit -Sn xxx" (needs a 2.2.13 or later Linux kernel). ulimit -Hn 8192 # Execute the program. eval exec "$4" FILES
/etc/inittab, /etc/initscript. AUTHOR
Miquel van Smoorenburg ,<miquels@cistron.nl> SEE ALSO
init(8), inittab(5). December 24, 1999 INITSCRIPT(5)
All times are GMT -4. The time now is 06:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy