LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-23-2004, 04:37 PM   #1
Scrag
Member
 
Registered: Mar 2004
Location: Wisconsin
Distribution: Kali Linux
Posts: 131

Rep: Reputation: 15
Unix source code


Anybody know where I can get source code for basic unix commands, like "cd" "ls", etc.

Thanks!

 
Old 05-23-2004, 04:41 PM   #2
xlord
Member
 
Registered: Mar 2002
Posts: 75

Rep: Reputation: 15
They are just compiled binary files.. you can do them your self, in c/python/perl/bash not hard
 
Old 05-23-2004, 04:49 PM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
I think they are contained in the coreutils package (search for "coreutils" on freshmeat.net).

I'm not absolutely positive they are part of that package, but it's likely to contain many basic utilities. Also, be aware that some of those commands are "builtin commands" for bash/tcsh/whatever. That means you would have to crack open your shell's source code to see how they implement it, because there would be no corresponding utility.
 
Old 05-23-2004, 04:51 PM   #4
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
http://www.gnu.org/directory/fileutils.html
 
Old 05-23-2004, 08:38 PM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,777

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
"cd" cannot be a standalone command, as useless when not a builtin.
 
Old 05-23-2004, 09:13 PM   #6
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Ya, cd is usually bultin to the shell. ls, dir, ect. are in the gnu fileutils package I linked to above.
 
Old 05-24-2004, 09:41 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,777

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
well, cd is not usually but *always* a shell builtin !
 
Old 05-24-2004, 03:49 PM   #8
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
True. "cd" is one of very few commands (the only?) you can be sure about that it is a shell built-in.
 
Old 05-24-2004, 04:02 PM   #9
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
and umask iirc
 
Old 05-25-2004, 02:28 AM   #10
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,777

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
Actually, there are plenty of builtin commands that couldn't technically be externalized like:
declare, set, unset, readonly, local, read, shift, dirs, popd, pushd, getopts, function, [un]alias, typeset, history, fg, bg, jobs, trap, eval, export, ulimit and "." (source).

Structural commands like "for", "select", "case", "return", "exit", "break" and the like can also only be embedded in the shell.

btw, cd was the first builtin command to be integrated in a unix shell (in the early seventies ...):

from: http://cm.bell-labs.com/cm/cs/who/dmr/hist.html

Quote:
Although the multiple-process idea slipped in very easily indeed, there were some aftereffects that weren't anticipated. The most memorable of these became evident soon after the new system came up and apparently worked. In the midst of our jubilation, it was discovered that the chdir (change current directory) command had stopped working. There was much reading of code and anxious introspection about how the addition of fork could have broken the chdir call. Finally the truth dawned: in the old system chdir was an ordinary command; it adjusted the current directory of the (unique) process attached to the terminal. Under the new system, the chdir command correctly changed the current directory of the process created to execute it, but this process promptly terminated and had no effect whatsoever on its parent shell! It was necessary to make chdir a special command, executed internally within the shell. It turns out that several command-like functions have the same property, for example login.

Last edited by jlliagre; 05-26-2004 at 03:04 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling C code Under Linuix verses Unix jonesth Programming 2 09-12-2005 08:02 AM
How to convert Assembly code to "C" source code ssg14j Programming 2 08-01-2005 12:48 PM
Unix log file as source for Oracle DB tornadoburn Programming 1 12-12-2003 06:47 PM
Unix source code stealing BOBO CONFIRMED! GtkUser General 1 06-07-2003 03:43 PM
Microsoft to license Unix code macewan General 6 05-27-2003 05:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration