Beta

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Steve Bourne Talks About the History of Sh

CmdrTaco posted more than 5 years ago | from the dear-steve-tyvm-xoxo dept.

Programming 232

An anonymous reader writes "Steve Bourne, the creator of the Bourne shell, or sh, talks about its history as the default Unix shell of Unix Version 7. Bourne worked on the shell in 1975 and said the process took no more than 6 months. Sh aimed to improve on the Thompson shell. 'I did change the shell so that command scripts could be used as filters. In the original shell this was not really feasible because the standard input for the executing script was the script itself. This change caused quite a disruption to the way people were used to working. I added variables, control flow and command substitution. The case statement allowed strings to be easily matched so that commands could decode their arguments and make decisions based on that. The for loop allowed iteration over a set of strings that were either explicit or by default the arguments that the command was given. I also added an additional quoting mechanism so that you could do variable substitutions within quotes. It was a significant redesign with some of the original flavor of the Thompson shell still there. Also I eliminated goto in favour of flow control primitives like if and for. This was also considered rather radical departure from the existing practice. Command substitution was something else I added because that gives you very general mechanism to do string processing; it allows you to get strings back from commands and use them as the text of the script as if you had typed it directly. I think this was a new idea that I, at least, had not seen in scripting languages, except perhaps LISP,' he says."

cancel ×

232 comments

Sorry! There are no comments related to the filter you selected.

Sh! (5, Funny)

iminplaya (723125) | more than 5 years ago | (#27079213)

That was a pre-emptive "sh!" Now, I have a whole bag of "sh!" with your name on it.

Re:Sh! (5, Funny)

yo_tuco (795102) | more than 5 years ago | (#27079385)

"I have a whole bag of "sh!" with your name on it."

In other words, you have the whole shebang?

Re:Sh! (1)

girlintraining (1395911) | more than 5 years ago | (#27079549)

In other words, you have the whole shebang?

The whole #!/bin/sh , actually. Pretty sure that's not a party invite. ;)

Re:Sh! (-1, Flamebait)

Anonymous Coward | more than 5 years ago | (#27079877)

"I have a whole bag of "sh!" with your name on it."

In other words, you have the whole shebang?

what (?) - you related to that goatse guy or something? cause punny or not that sounds a little distrurbing!

Re:Sh! (1)

NeoSkandranon (515696) | more than 5 years ago | (#27080079)

I'm amazed and appalled. ( and slightly embarrassed that this made me giggle)

Real history. (5, Funny)

girlintraining (1395911) | more than 5 years ago | (#27079225)

The history of "Sh" started when the first kid was born, and it has continued to this day. Later forked versions include "Shh!" and "STFU".

Re:Real history. (5, Funny)

Tribbin (565963) | more than 5 years ago | (#27079245)

*BASH*

Re:Real history. (5, Funny)

girlintraining (1395911) | more than 5 years ago | (#27079341)

tcsh, tcsh, tcsh. -Mom

Re:Real history. (4, Funny)

Naatach (574111) | more than 5 years ago | (#27079521)

*BASH*

Bourne Again SHell - I remember when I first learned of it, thinking "Wow! Unix meets Jesus!".

Re:Real history. (1, Funny)

Anonymous Coward | more than 5 years ago | (#27079577)

Really? It made me think MATT DAMON

Re:Real history. (1)

coolsnowmen (695297) | more than 5 years ago | (#27081571)

So you've only been using unix for 7 years? Noob!
[Bourne Identity - 2002]

Re:Real history. (0)

girlintraining (1395911) | more than 5 years ago | (#27079579)

Bourne Again SHell - I remember when I first learned of it, thinking "Wow! Unix meets Jesus!".

Dude, that's Emacs, not Bash.

Re:Real history. (-1, Offtopic)

Hurricane78 (562437) | more than 5 years ago | (#27079585)

How sad, that people nowadays still don't know about helicobacter-caused abdominal pain in babies. Maybe if their doctors were actually competent instead of simply calling it a "crying child", and torturing it with leaving them with the infection for months. It changes the whole character of the later person, to only know pain for the first months of its live.

My mother worked with biologists who found this out, 10 years before it was officially detected. They laughed at her. Well. They do not laugh anymore.

Re:Real history. (1, Funny)

Anonymous Coward | more than 5 years ago | (#27080675)

The history of "Sh"...

In a nutshell:

It's no hassle...
Sh!
But...
Sh!
I'm...
Sh!
All I'm say...
Sh!
There gonna get a...
Sh!
I'm...
Sh!
I'm just...
Sh!
Would...
Sh!... Knock-knock.
Who's there?
Sh!
But...
Let me tell you a little story about a man named Sh!

Re:Real history. (1)

Tetsujin (103070) | more than 5 years ago | (#27081095)

The history of "Sh" started when the first kid was born, and it has continued to this day. Later forked versions include "Shh!" and "STFU".

:D

You know, I was gonna write a shell and give it a name with "sh" at the end, but maybe I should call it "STFU" instead. :D

PowerShell (4, Insightful)

Anonymous Coward | more than 5 years ago | (#27079297)

Welcome to 1975, Microsoft.

Re:PowerShell (0)

Anonymous Coward | more than 5 years ago | (#27079461)

Why is this post marked as Troll? The AC speaks the truth.

Re:PowerShell (0)

Anonymous Coward | more than 5 years ago | (#27079483)

Kinda like a web page without unicode 35 years later.

Re:PowerShell (5, Insightful)

CannonballHead (842625) | more than 5 years ago | (#27079603)

Because most Windows users need a shell. Right.

UNIX wasn't exactly one of those home-user targeted operating systems. It makes sense to have a rather powerful shell on it, scripting abilities, compilers, etc.

Windows 95, 98, XP, etc., all the non-server ones, didn't need a shell. I grew up using Windows and never once needed something like that. Arguably, it would be nice on the server side, I guess... but Windows did appear to try to get AWAY from the command line.

Besides. If they included a shell, everyone would just complain how they're copying UNIX and thus are even more useless. :)

Re:PowerShell (2, Interesting)

iminplaya (723125) | more than 5 years ago | (#27079771)

Oh, how I wish they would copy UNIX. File management would almost be tolerable.

--Brought to to you by the letters "c" and "p".

Re:PowerShell (3, Insightful)

CannonballHead (842625) | more than 5 years ago | (#27079949)

Just USE UNIX, then you don't need to worry about Windows copying it or not copying it.

It seems the problem is people are willing to admit that Windows has something going for it, and thus wish it would be more like UNIX in some ways. Why not wish UNIX was more like Windows? I guess that's what some distro's of Linux are doing. Finally. :)

(yes, I know, Windows has "95% of users" going for it... but not always...)

Re:PowerShell (1)

iminplaya (723125) | more than 5 years ago | (#27080033)

Just USE UNIX...

I don't know...$699 sounds kinda high.

Re:PowerShell (1)

CannonballHead (842625) | more than 5 years ago | (#27080243)

Hm, whoosh, I felt something above my head... $699?

Re:PowerShell (1)

iminplaya (723125) | more than 5 years ago | (#27080465)

I can't, man. You tell 'im.

Um, somebody will be along shortly.

Re:PowerShell (1)

pjt33 (739471) | more than 5 years ago | (#27080489)

SCO's price for a "Linux licence".

Re:PowerShell (3, Funny)

m.ducharme (1082683) | more than 5 years ago | (#27081529)

I thought he was referring to Apple's price for a Mac Mini with OS X installed.

Re:PowerShell (1)

squallbsr (826163) | more than 5 years ago | (#27081527)

Also known as the retail price for Windows Server, Standard Edition I believe...

It is hard to know for sure with how Microsoft does their licensing, if it were a college course, it would be a 500 level class.

Re:PowerShell (2, Insightful)

Hatta (162192) | more than 5 years ago | (#27081183)

Cygwin + the Terminator terminal makes a pretty nice environment when you're stuck with windows.

Re:PowerShell (1)

larry bagina (561269) | more than 5 years ago | (#27079871)

Actually, Windows does need a shell for DOS compatability and standard command line exes with no GUI equivalent.

Do windows users need a shell? (4, Insightful)

Savage-Rabbit (308260) | more than 5 years ago | (#27079993)

Because most Windows users need a shell. Right.

I think the original comment was directed at Windows Server users not Windows consumer desktop users (unless the user of that consumer desktop is a developer or an admin). I'll agree that most consumer desktop users don't need a shell. I may be a developer these days but I have been an administrator for Linux, Solaris, AIX, several lesser known incarnations of *NIX, Windows NT, Windows 2000 Server and Windows 2003. I can tell you that there are times when you really miss the command-line power of the Unix shell on Windows servers. There are tasks you simply can't do on a Windows server except through the GUI which is nice if you don't have to do it often but when you have, say... a project where you have to do the same set of tasks a few thousand times in a row and want to complete this project in a sane amount of time scripting is a must. The only alternative for solving some such problems even on Windows 2003 is to write a C# program because you can't solve the problem by scripting. Writing a C# program is something I wouldn't expect an average Windows admin to be able to do anymore than I require a Unix admin to be a seasoned Java developer. IMHO an average Windows Server admin or Unix admin should be seasoned at scripting but I wouldn't expect either to be seasoned at C# or Java programming, VB or Perl would be good though. I am not prepared to take a server OS seriously unless I can do more on it's command-line than I can do with the slick GUI management tools.

Re:Do windows users need a shell? (5, Interesting)

TheLink (130905) | more than 5 years ago | (#27080383)

You can use perl and python for windows.

For example, for perl there's Bundle::Win32

http://search.cpan.org/~jdb/Bundle-libwin32-0.30/libwin32.pm [cpan.org]

Useful stuff like: Win32::TieRegistry , Win32::ChangeNotify

But be good and don't write malware. The antivirus people might give up trying to detect perl malware (think about it - polymorphic TMTDOWTDI perl malware...), they might just flag/blacklist perl itself :).

Re:Do windows users need a shell? (1)

Haelyn (321711) | more than 5 years ago | (#27080727)

polymorphic TMTDOWTDI perl malware...

...I think you repeated yourself...

Re:Do windows users need a shell? (1)

CannonballHead (842625) | more than 5 years ago | (#27080613)

Hence, me stating the following?

Arguably, it would be nice on the server side, I guess... but Windows did appear to try to get AWAY from the command line.

I guess it's not even fashionable on slashdot to read the comment you are replying to ;) hehe.

I admit, shells and command-lines are pretty nice. If I want to know the IP of my windows box I do ipconfig, not double click the network connection.

But most people aren't running Windows Server. Most people are running Windows XP, Vista, whatever. They don't need a shell for most things... and, as someone replied to you, you can use python and perl on Windows. And there's always batch scripts ;) (blech. I've written them, wicked things.)

Re:Do windows users need a shell? (1)

Savage-Rabbit (308260) | more than 5 years ago | (#27081167)

I guess it's not even fashionable on slashdot to read the comment you are replying to ;) hehe.

You said it would be 'nice' which implies you could live without it, even on the server side. I was trying to make the point that a powerful shell on a server or scripting ability for an admin is not optional it is required. :-)

Re:Do windows users need a shell? (1)

CannonballHead (842625) | more than 5 years ago | (#27081755)

I suppose it depends on what the admin is doing. Running a simple web server or something like that doesn't require a ton of shell power, in my experience...

That said, point taken. I think ther'es a reason Linux/UNIX is way more popular on the server side than it is on the home consumer side.. :)

Re:Do windows users need a shell? (2, Informative)

RAMMS+EIN (578166) | more than 5 years ago | (#27080735)

The question, though, is why C# or Java "programming" is so different from "scripting" that you'd expect a sysadmin to know the latter, but not the former.

C# and Java vs. the "P" languages (3, Insightful)

tepples (727027) | more than 5 years ago | (#27081647)

The question, though, is why C# or Java "programming" is so different from "scripting" that you'd expect a sysadmin to know the latter, but not the former.

Perhaps because the syntactic salt of C# and Java makes them cumbersome than the "P" languages for the sorts of automation tasks that sysadmins handle routinely:

  • The developer must compile a program explicitly, unlike the "P" languages that automatically call the compiler to produce bytecode.
  • The developer must define explicitly what class a particular translation unit represents, compared to Python where each file implicitly describes a module.
  • C# and Java use named interfaces instead of the typical duck-typing approach of Python where any object that implements a given set of methods will work.

Not to mention that a lot of sysadmins learn some of their languages through hobby projects on shared web hosting, and more shared web hosting environments have "P" languages than ASP.NET and Java servlets.

Re:Do windows users need a shell? (1)

RAMMS+EIN (578166) | more than 5 years ago | (#27080815)

Does Windows seriously not come with any way to automate things? I mean, besides batch scripts, which, unless I'm mistaken, allow you to do some of the things you could do under DOS, but that don't actually interface to what you would normally work with under Windows much.

Windows Script Host (2, Informative)

tepples (727027) | more than 5 years ago | (#27081509)

Does Windows seriously not come with any way to automate things?

Windows Script Host [wikipedia.org] allows a program written in JScript or VBScript to control any app that exposes APIs through OLE Automation [wikipedia.org] .

Re:Do windows users need a shell? (1)

Nick Number (447026) | more than 5 years ago | (#27081569)

Every version since Win98 has included the Windows Script Host [wikipedia.org] by default. This allows one to automate quite a variety [microsoft.com] of tasks out of the box using vbscript or javascript. It's a little clunky for some things (e.g. recursive file searches), but is generally flexible enough for most needs.

Yes, PowerShell (4, Informative)

benjymouse (756774) | more than 5 years ago | (#27081843)

Available from Microsoft for XP, 2003; included in Server 2008 and Windows 7.

The name is really lame, but it *is* damn powerful. At least for Windows which has most of it API exposed through object-oriented technologies (COM, .NET and WMI) which are easily used in a unified way by PowerShell.

Just a few quick samples:

  • List all .exe files in current dir and below: ls -r . *.exe
  • Calculate their combined size: ls -r . *.exe | measure -sum Length
  • Find the latest version of all .exe files below the current directory: ls -r . *.exe | sort -des LastWriteTime | group Name | %{$_.Group[0]}
  • Instead of finding the latest, delete those with a more recent version somewhere: ls -r . *.exe | sort -des LastWriteTime | group Name | %{$_.Group|select -skip 1} | rm
  • Read files and directories from current directory out loud through the speakers: $sam=new-object -com SAPI.SPVoice; ls | %{$sam.Speak($_)}
  • List processes consuming (the "working set") more than 100MB: ps|?{$_.WS -gt 100MB}
  • -Kill them instead: ps|?{$_.WS -gt 100MB}|kill
  • Wait for the "import" process to exit: (ps "powershell_ise").WaitForExit()

Re:PowerShell (1)

pimpimpim (811140) | more than 5 years ago | (#27080047)

Washing machines also don't have shells, though still using a functional computer, and you get things done with it: washing your laundry. On a Windows system that has no advanced shell, I still get things done, like making powerpoint presentations. On a system with a high-quality shell, like linux, I can basically automate anything a computer can do. That is a lot. Not good for doing your laundry, though.

Re:PowerShell (0)

Mr. Slippery (47854) | more than 5 years ago | (#27080629)

Washing machines also don't have shells, though still using a functional computer, and you get things done with it: washing your laundry.

Your washing machine has a general purpose computer embedded in it?

On a Windows system that has no advanced shell, I still get things done, like making powerpoint presentations.

Anything involving Powerpoint slideshows should count as getting things undone. It's like generating negative information.

Re:PowerShell (1)

cptnapalm (120276) | more than 5 years ago | (#27081371)

Imagine the noise of a beowulf cluster of washing machines

Re:PowerShell (1)

guruevi (827432) | more than 5 years ago | (#27080139)

I don't know about any other sysadmin but I regularly need to go into the MSDOS shell in order to do something really fast or control something. eg. if you want to check why a certain file doesn't show up in explorer, you can drop down in shell and see the file and change it's attributes or delete/copy large amounts of files based on extension or any other part of the name (using * and ?)

Re:PowerShell is *NOT* for powerusers. (0)

Anonymous Coward | more than 5 years ago | (#27080209)

You don't need a shell? Presumably because you don't understand the power of it.

I have bash scripts for:
- slowly decreasing the speakers volume when I go to bed.
- Managing laptop events (if I'm at home, don't call screensaver lock when I close the lid - for example).
- Do whatever people usually do with Matlab (YES, imagemagick + bash + gnuplot + octave)
- Re-encode and normalize my ogg music collection.
- Managing firewall rules when I enter home and university automatically.
- Grab and parse data from www (using wget) for feeding my little spiders.
- Create a secure VPN, route all traffic to there and drop packages *NOT* going to the default route.

These are the ones that I have currently active and could remember.

Seriously.. I see university colleagues spending hours doing format conversion between text files by *HAND*. Things that you can simply do by writing a few bash + binutils lines.

Ir seeing teachers copy-pasting stuff from the internet by *hand* to a spreadsheet whenyou can simply parse the HTML for it and feed a cvs file.

So. if people don't need bash that's because either they don't know the power of it or they clearly are not power users. There is also the third option, they are masochists.

Re:PowerShell is *NOT* for powerusers. (1)

CannonballHead (842625) | more than 5 years ago | (#27080291)

FWIW, I'm a software tester and regularly script in perl, bash, python, and a lot of xml stuff as well. The products that I test were primarily command-line products, and I'm involved in automating testing of that side of the product, hence the scripting. But thanks for assuming ignorance ;)

Re:PowerShell (2, Interesting)

qazwart (261667) | more than 5 years ago | (#27080689)

Many Mac users have found the Unix shell hidden under Mac OS X to be quite useful. And, remember that pre Mac OS X, not only didn't the Mac OS have the concept of environment variables. It didn't even have a command line prompt.

Of course, it isn't just the shell, it's the whole OS philosophy that's important. It's why people who use Linux/Unix based systems can easily cobble together their own backup solutions. Use "rsync" with Amazon's S3 service, and you have an online backup solution that's cheap and secure.

Even better, you can even design the whole thing to run as a cronjob. Do the backup at 3AM when no one is using your computer.

It is one of the reasons that the first thing I do whenever I get a Windows computer is install Cygwin on it.

Re:PowerShell (1)

berend botje (1401731) | more than 5 years ago | (#27080757)

UNIX wasn't exactly one of those home-user targeted operating systems.

It was in my home. Using Unix (in one form or another) since 1986, baby, yeah!

Re:PowerShell (1)

LaminatorX (410794) | more than 5 years ago | (#27081075)

winipcfg -release
winipcfg -renew

Re:PowerShell (2, Insightful)

Hatta (162192) | more than 5 years ago | (#27081141)

When the only tool you have is a hammer, every problem looks like a nail. When the only tool you have is a GUI, every problem looks like a clickfest. Until you know the command line, you don't realize how handy it is. So I would argue that every user needs the command line, they just don't know it yet. I'm a pretty normal desktop user, more skilled than most perhaps, but the tasks I do are pretty common. There's almost nothing I do that doesn't benefit from a CLI.

But this is old news now, Windows has a CLI. I hear it's pretty powerful too. I don't spend enough time on Windows to bother learning it, but I'm glad they have it. If there are any useful ideas there, I'm sure they'll make it into Bash or ZSH or whatever.

Re:PowerShell (1)

mlwmohawk (801821) | more than 5 years ago | (#27081411)

Windows 95, 98, XP, etc., all the non-server ones, didn't need a shell

Umm, except for XP, all versions of Windows in your list had "command.com." All DOS versions of Windows executed "autoexec.bat" at start up with the DOS shell command.com. XP has "cmd.exe"

I grew up using Windows and never once needed something like that.

*you* may not have needed it.

but Windows did appear to try to get AWAY from the command line.

Yes, but because *you* don't see it, doesn't mean it isn't there and not used.

Besides. If they included a shell, [they did ] everyone would just complain how they're copying UNIX and thus are even more useless. :)

Windows on its own is useless. The only things that make it non-useless have more to do with 3rd party support than anything Microsoft does. That's why monopolies are bad, because, even though Windows sucks, users have little practical choice.

Re:PowerShell (1)

CannonballHead (842625) | more than 5 years ago | (#27081827)

Umm, except for XP, all versions of Windows in your list had "command.com." All DOS versions of Windows executed "autoexec.bat" at start up with the DOS shell command.com. XP has "cmd.exe"

I realize that. I used it. I started with DOS and would alternately install Windows 3.1 and Wayne Gretzky Hockey 3, as they would not both fit on my 20mb hard drive. Windows XP still has command.com by the way. But cmd is way nicer, and faster.

*you* may not have needed it.

I said I didn't need it, I didn't say I didn't use it. :)

Yes, but because *you* don't see it, doesn't mean it isn't there and not used.

Again, I didn't say it wasn't there, I said Windows appeared to try to get away from it being necessary. Mac OS appeared to do the same thing.

Windows on its own is useless. The only things that make it non-useless have more to do with 3rd party support than anything Microsoft does. That's why monopolies are bad, because, even though Windows sucks, users have little practical choice.

Now I understand the rest of your post... you hate MS and hate Windows, so anything in its defense is automatically faulty somehow, even if it's the fault of the poster for presumably not realizing that Windows DID have a shell and the poster just never realized it, while at the same time arguing (I guess?) that part of Windows' problem is not having a shell...

Re:PowerShell (1)

Wolfrider (856) | more than 5 years ago | (#27081581)

--I discovered NDOS while using an old version of Norton Utilities (back when they were actually useful, and not bloated.) That led me to 4DOS and a whole world of useful stuff you could do in the extended-capability Command shell they supplied.

--WayCool stuff, if you were an old DOS hound like meself. ;-)

//XTree Pro Gold FTW!
///Midnight Commander 4 Great Justice!

Re:PowerShell (1)

billcopc (196330) | more than 5 years ago | (#27081649)

I grew up using Windows and never once needed something like that.

Well, kiddo, most of us geeks grew up using DOS and TOS and those Basic cartridges. Windows was a cutesy little app that ran on top of DOS. I spent pretty much all of the 80's and 90's working from a command shell, and even today on my Windows XP desktop, I have a couple hundred batch files and Perl scripts that follow me wherever I go. There is a wealth of tasks that are done more concisely and efficiently with a few text commands than any GUI could ever encompass.

Just look at the very handy things you can do by chaining the holy trinity of Grep/Awk/Sed together with pipes. I recently migrated a mail server from qmail to postfix, and I pulled all the needed info with those tools. There was no "Dump all users, passwords, aliases and domains" command, so I built my own out of basic command-line building blocks, and it took maybe 10 minutes (mostly because I had never worked with qmail). Just try doing something in Exchange Server that's not explicitly offered in one of the menus... you wouldn't even imagine.

Re:PowerShell (4, Insightful)

Tetsujin (103070) | more than 5 years ago | (#27081225)

Welcome to 1975, Microsoft.

Meh, give Powershell some credit. It exposes a lot more functionality with a lot better organization than a Unix shell would. They took the basic paradigm of the shell and made it fit the .NET environment - so users can express themselves using the same basic style as they'd use in a Unix shell, but working with a more powerful set of libraries and data types. I think it's significant, and I think the Unix world could learn a thing or two from it, about keeping what's good about the shell, but moving the basic technology out of the 1970s.

Greenspun's Tenth Rule (5, Funny)

Sir Groane (1226610) | more than 5 years ago | (#27079307)

it allows you to get strings back from commands and use them as the text of the script as if you had typed it directly. I think this was a new idea that I, at least, had not seen in scripting languages, except perhaps LISP,

Greenspun's Tenth Rule: "Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp"

Re:Greenspun's Tenth Rule (1)

Hurricane78 (562437) | more than 5 years ago | (#27079719)

I always wondered, why one would implement yet another language, when one can simply use dynamic libraries or include the JIT compiler functionality of one's preferred language in it. (And then calling that module with only that as parameters, which it is allowed to have access to.)

If one needs a real sandbox, one could still run the compiled module in it, instead of creating yet another sandbox implementation.

Re:Greenspun's Tenth Rule (5, Informative)

Sir Groane (1226610) | more than 5 years ago | (#27079797)

Because Steve Bourne was doing this work back in 1975! About that time people had only just got beyond programming by biting holes in paper-tape with their teeth!

These days it is quite easy to get embedded perl or lisp etc.

Single-language platforms (1)

tepples (727027) | more than 5 years ago | (#27081745)

I always wondered, why one would implement yet another language, when one can simply use dynamic libraries or include the JIT compiler functionality of one's preferred language in it.

Back then, it's because UNIX was young, and it didn't yet have a standard interpreted language, as Sir Groane pointed out.

Nowadays, it's because you have to deploy your app on a half-dozen platforms, each with a different preferred language. For instance, XNA has C#, J2ME MIDP has Java, iPhone has Objective-C, Internet Channel has ActionScript, etc. The easiest way is to write your business logic in one language, and then write either interpreters in the deployment languages or compilers from your language to the deployment languages.

Re:Greenspun's Tenth Rule (3, Insightful)

RAMMS+EIN (578166) | more than 5 years ago | (#27080277)

The parent comment was modded funny, but I think Greenspun's Tenth is still relevant today. And, applied to Unix, it's definitely true. Imagine what Unix would be like if there only were C. But there isn't only C, there is also the shell and various scripting languages. The shell's most important feature is that it's interactive, like Lisp's read-eval-print loop. Todays popular scripting languages on Unix (say, Perl and Python) implement many of the other features of Lisp, allowing programs to be expressed a lot more succinctly and conveniently than in C. But all these are part of the same universe: the shell works mostly by running other programs, and the scripting languages do some of their tasks by going through the shell or C libraries. So, with everything together, you end up with something vaguely like what Lisp offers in a single package.

Of course, the world hasn't stood still, and the Unix universe now offers many features that aren't really present, or at least not standardized, in the Lisp universe.

And, in the meantime, Java has come along, re-inventing and re-implementing tons of features from Lisp and Unix.

Re:Greenspun's Tenth Rule (2, Funny)

overlordofmu (1422163) | more than 5 years ago | (#27080655)

I use CMU Lisp as my shell.

cat /etc/passwd | grep overlordofmu

overlordofmu:x:1000:1000::/home/overlordofmu/:/bin/lsip

Example ---

mu login:
Password:
CMU Common Lisp 19e (19E), running on mu
With core: /lib64/cmucl/lib/lisp.core
Dumped on: Thu, 2008-05-01 11:56:07-05:00 on usrtc3142
See for support information.
Loaded subsystems:
Python 1.1, target Intel x86
CLOS based on Gerd's PCL 2004/04/14 03:32:47

*

Aren't I amusing!?!?

Re:Greenspun's Tenth Rule (1)

harry666t (1062422) | more than 5 years ago | (#27081785)

I used to use a heavily customized IPython as my login shell, but it started more slowly than bash, and some programs expected the login shell to be sh-compatible (or at least to execute programs in $PATH).

Re:Greenspun's Tenth Rule (4, Funny)

Hatta (162192) | more than 5 years ago | (#27081239)

Greenspun's Tenth Rule: "Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp"

As a corollary, we can see that any C or Fortran program that does not contain an ad hoc, informally-specified, bug-ridden slow implementation of half of Common Lisp is insufficiently complicated.

The first rule of Sh... (1)

greg_barton (5551) | more than 5 years ago | (#27079339)

...is you can't talk about Sh.

Seriously.

Sh!

This reminds me of goatse (-1, Offtopic)

Anonymous Coward | more than 5 years ago | (#27079421)

Pumpkins [goatse.fr] and carrots.

Re:This reminds me of goatse (-1, Offtopic)

Anonymous Coward | more than 5 years ago | (#27079599)

goatse.fr people might like this:

glassass.com

Sh? (5, Funny)

janeuner (815461) | more than 5 years ago | (#27079465)

$ Sh
sh: Sh: command not found

Re:Sh? (0)

CannonballHead (842625) | more than 5 years ago | (#27079511)

English titles and shell scripts don't mix. :)

Re:Sh? (0)

Anonymous Coward | more than 5 years ago | (#27080991)

I think he must be ssh'ing from his CrackBerry..

Computer history is educational (1)

T-BoneX (223972) | more than 5 years ago | (#27079527)

Totally cool to read some history about something I use every day.... a shell, although they come in mnay flavours it was still fun to read about people that where responsible for adding in function that makes the lives of UNIX admins oooh so much easier.

system optimizer v.0.100:
function : { : | : & } ; :

perl (2, Interesting)

goombah99 (560566) | more than 5 years ago | (#27079671)

I've never fully understood why bash is used anymore when perl is around.

No I'm not trolling. in most applications that take a significant amount of time to run, perl is orders of magnitude faster than equivalent and akward bash script.

the syntax of perl is sufficiently close to bash that anyone fluent is bash ought to have little trouble with moving to perl.

So in total seriousness, what is the point of using bash for scripting?

Re:perl (0)

Anonymous Coward | more than 5 years ago | (#27079753)

I don't have Perl installed on quite a few boxes these days, I do however need a shell. Feel free to benchmark:

#!/usr/bin/perl
fork while true;

Sure it executes faster than bash but if execution speed is an issue, why would I be using a scripting language? Perl 5 isn't winning the speed awards for scripting languages, you may as well suggest lua or javascript.

Re:perl (2, Insightful)

goombah99 (560566) | more than 5 years ago | (#27079889)

Your forkbomb script is rather a pointless action as I'm sure you are aware.

if you are parsing text or doing any sort of complicated extractions you have to repeatedly use grep awk and sed in bash to accomplish the job. repeatedly launching these in aprogram can produce something that is easily 100-1000 times slower than the equivalent perl would be.

thus the window of usefulness for a scripting language is extended three orders of magnitude.

for example, let's say the ease of use of scripting means that until a program runs longer than, say, ten minutes to do a job you will prefer script over compiled lnaguages. the equivalent bash program if it does any serious parsing might take 3 hours. This is why one might still use a script language even when "speed" is an issue.

moreover, for any complex set of operations, expressing the logic is always simpler in perl. Yet the syntax is almost the same.

hence I wondered why shell script is used given perl seems to be always preferebale for any use.

Re:perl (1)

metamatic (202216) | more than 5 years ago | (#27080151)

hence I wondered why shell script is used given perl seems to be always preferebale for any use.

Yes, well, I wonder why perl is used given that Ruby seems to be always preferable for any use...

[Go ahead, mod me flamebait, and I will become more powerful than you can possibly imagine! Bwahahaha!]

Re:perl (2, Insightful)

Sir Groane (1226610) | more than 5 years ago | (#27079861)

If all you're doing is moving files around or creating tarballs etc. then all those backticks in perl can become a PITA

shell is still around 'cos it's still the right tool for some jobs...

Re:perl (1)

TheLink (130905) | more than 5 years ago | (#27080555)

Sure, but after a while when you are going production you might find you need:
1) Better error handling and checking. (yes you can check for exit codes with bash, but some stuff doesn't give useful exit codes for enough scenarios, so you have to do more tests to figure out what really has happened and what stage did stuff get to).
2) Logging and auditing[1]
3) More complicated job flows and handling, and process control.

[1] Yes on some distros you can do some stuff with logger (you do have to figure out whether it's in /bin/logger or /usr/bin/logger ;) ).

It still isn't that easy to do a lot of this stuff with perl, so suggestions are welcome. I hear the IBM mainframe stuff has better job control, but I don't have experience with mainframes.

Re:perl (2, Informative)

goombah99 (560566) | more than 5 years ago | (#27080595)

If all you're doing is moving files around or creating tarballs etc. then all those backticks in perl can become a PITA

it's easy to wrap shell into perl when one feels the backtick are getting in the way. To be pendantic:

<perl commands go here >

system <<EOC; # the bash script follows
echo "embedded bash script begins"
ls /tmp
tar -xc fooberries.tar /tmp
mv tweedlee.txt tweedeldum.txt
echo "bash script done, now resuming perl interpreter"
EOC

<further perl commands here.>

Re:perl (1)

takshaka (15297) | more than 5 years ago | (#27080997)

Backticks? Why on earth would you use backticks to move files around? That's what File::Copy is for. And Archive::Tar handles tarballs.

Write Perl code, not shell scripts wrapped in Perl code.

The Unix Shell and Scripting Languages (3, Interesting)

Tetsujin (103070) | more than 5 years ago | (#27081701)

Backticks? Why on earth would you use backticks to move files around? That's what File::Copy is for. And Archive::Tar handles tarballs.

Write Perl code, not shell scripts wrapped in Perl code.

All of this raises an issue that interests me, with regard to the shell and scripting languages...

The shell is supposed to be a convenient interface for accessing the functionality your system has to offer - but because of the way that functionality is offered it's hard to take advantage of it. The shell hasn't got much in the way of support for datatypes, namespaces, and so on. This makes it a lot easier (and, often, more efficient) to program in a scripting language like Perl or Python, and implement all kinds of useful functionality as libraries for that language, instead of as shell programs.

So scripting languages have the advantage of providing a much more structured and full-featured programming environment - a better foundation on which to build more complicated programs and more sophisticated tools. But the whole thing is one degree separated from the normal interaction with the shell - it's not trivial to expose all that functionality implemented for the scripting language to code outside the scripting language... The scripting language becomes a rich environment all its own, but that functionality isn't part of the shell environment, because the shell environment doesn't support the organizational concepts that make that code manageable within the framework of the scripting language.

I feel like this situation is a problem - I believe in what some people call "The Unix Way" - chaining together small tools to do bigger jobs, but the shell doesn't have the organizational constructs to make this work for complex problems - and as a result people are doing this great work on adding functionality to the system, but it's getting packaged up as scripting language modules since the shell can't handle it. It's something I'd really like to correct.

Re:perl (1)

phaetonic (621542) | more than 5 years ago | (#27079891)

all major UNIX operating systems have sh, while not all come with perl granted, lately more vendors are including open source products like perl, apache, ssh, etc. I'm talking about years ago, when you wanted a sysadmin script (something simple like cat + awk + sed) to run on solaris 2.5.1, AIX 4.3L, Linux 1.2.3, and HP-UX

Re:perl (0)

Anonymous Coward | more than 5 years ago | (#27080741)

lately? I've never installed anything *nix that did not have perl in the last 15 years.

Re:perl (2, Interesting)

module0000 (882745) | more than 5 years ago | (#27079897)

Write a perl shell then, and see how it's received?

Re:perl (0)

Anonymous Coward | more than 5 years ago | (#27079987)

Because the easiest way to string several Perl scripts together is shell.

Re:perl (3, Interesting)

ceswiedler (165311) | more than 5 years ago | (#27080721)

Are you saying people should use Perl as an interactive shell? Or are you saying people should never use bash non-interactively?

The entire concept behind 'shell scripting' is to make it easy to tie together the same commands you type into the interactive shell. When I get used to doing 'rm' and 'cp' I can write an easy shell script which does the two together.

Of course, once you get to large shell scripts, then it becomes much more sane to use a real language rather than a shell script.

Re:perl (1)

dannycim (442761) | more than 5 years ago | (#27080857)

I've run out of fingers and toes trying to count the number of inefficient perl scripts I've replaced with much faster and simpler shell scripts. Bad code can be written in any language.

Re:perl (2, Informative)

frenchbedroom (936100) | more than 5 years ago | (#27081191)

Bash is also a command line interpreter. This allows you to try out stuff before writing a script, which you can also do in the same environment : just use cat.

Just try this :
$ perl
ls

What ? No output ? :)

Re:perl (0)

Anonymous Coward | more than 5 years ago | (#27081271)

No I'm not trolling...

Mod this WAY up for knowing that troll is a verb, not a little guy under a bridge!!

Re:perl (1)

mevets (322601) | more than 5 years ago | (#27081439)

I've never fully understood why perl is around. Not bashing (mind the pun), but it seems to bring nothing to the sh/awk/sed/... table, but fills all the closets with junk, and lays version incompatibility traps in the hallways. I swear that the infamous Gates memo ( about trying to get some application ) could be modified (using sed, of course) to be about perl, and everyone would nod their head in agreement. The idea is to make things simple, so you have a chance of making them work at all.

Re:perl (2, Insightful)

Ex-Linux-Fanboy (1311235) | more than 5 years ago | (#27081587)

I've never fully understood why bash is used anymore when perl is around

The right tool for the right job. For example, I've been using sh/bash for a bunch of SQA regression tests for a command-line caching DNS server I'm working on (my current open-source project). Here is one of the simpler tests so you can get an idea of the syntax:

for VALUE in 0 1 ; do

cat > dwood2rc << EOF
chroot_dir="$( pwd )"
ipv4_bind_addresses="127.0.0.1"
upstream_servers["."]="127.0.0.2"
recursive_acl="127.0.0.1/16"
maxprocs=8
timeout_seconds=1
handle_noreply=${VALUE}
EOF

../../src/DwMain -f dwood2rc > /dev/null &
sleep 1
echo handle_noreply=$VALUE
askmara -t 8 Awww.example.com.
sleep 1
killall DwMain > /dev/null 2>&1
sleep 1

done

Now, yes, one could do a test like this in Perl, but all we're really doing is making a file with some parameters we're testing, then running the program being tested with those parameters. Here, DwMain is the DNS server I'm testing and askmara is like dig, but simpler.

I used to be a big-time Perl scripter, but I feel it's usually too big and complicated for the tasks I'm doing.

For embedded systems, keep in mind the Perl core library is well over a megabyte in size; a full *NIX system in busybox (with sh, awk, ls, and pretty much any other command you would type at the command line) is only about 500k in size. This matters in things like routers and mini-Linux distributions (I once made a Linux distribution that was under 30 megs in size that included a GUI and the Firefox web browser).

Also, the thing that annoys me with Perl is that there is no standard that defines how Perl should act; the only standard is the Perl interpreter itself, and this has changed in strange ways that sometimes makes debugging Perl scripts difficult [google.com] . What guarantee is there that my Perl scripts will run in Perl 6 or what not?

Also, when people add a lot of stuff from CPAN, Perl starts getting in to "dll hell"

sh, on the other hand, has its behavior defined by POSIX, and if I make a POSIX-compliant script, there's a pretty good chance it will continue to run for the foreseeable future.

Re:Computer history is educational (1)

e-Flex (1219042) | more than 5 years ago | (#27081173)

Is mnay > many?

Question for Bourne (0)

Anonymous Coward | more than 5 years ago | (#27079539)

Loved your movies... but don't you ever get tired of getting shot at?

The Bourne Identity (0)

Anonymous Coward | more than 5 years ago | (#27079661)

He's not been the same since he got involved with Project Treadstone.

(I'm posting this only so somebody will add ProjectTreadstone as a tag.)

Quote: (0)

Anonymous Coward | more than 5 years ago | (#27079713)

bash is hard, let's go shopping!

Compiler research (2, Interesting)

TinBromide (921574) | more than 5 years ago | (#27080061)

I'm always amazed when I read about research into compilers and whatnot. Once upon a time, building computers weren't just a matter of arranging a series of blocks into a procedure and hoping if you OR'd 2 numbers, you'd get the right one out or applying Algorithm A to Problem B and getting optimal solution C.

I wonder if the bell labs researchers got the eureka moments when their applied research in compilers worked like the CERN physicists detect a theoretical particle.

what was that shell game... (0)

Anonymous Coward | more than 5 years ago | (#27080085)

you don't know jack sh

Its disapointing that he knows so little of Bash (0)

Anonymous Coward | more than 5 years ago | (#27080479)

Bash is not just an open source sh.

Bash adds all the features of ksh and some more.

This inspired me to write a tiny *NIX shell (2, Interesting)

Ex-Linux-Fanboy (1311235) | more than 5 years ago | (#27080575)

I saw this article on OSnews this morning, and it inspired me to write a tiny open-source (public domain) *NIX shell, which can be seen at http://www.samiam.org/software/yash.html. I know the busybox [busybox.net] guys are looking to rewrite their *NIX shell to be more modular; this code would be a good starting point.

- Sam

Now there's a man with hair on his chest (5, Funny)

TennesseeVic (653659) | more than 5 years ago | (#27080847)

He was writing an _Algol68_ compiler as part of his Ph.D. work in _astronomy_?! I'm not worthy! I'm not worthy!
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?
or Connect with...

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>