Slashdot Mirror


Steve Bourne Talks About the History of Sh

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."

52 of 232 comments (clear)

  1. Sh! by iminplaya · · Score: 5, Funny

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

    --
    What?
    1. Re:Sh! by yo_tuco · · Score: 5, Funny

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

      In other words, you have the whole shebang?

  2. Real history. by girlintraining · · Score: 5, Funny

    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".

    --
    #fuckbeta #iamslashdot #dicemustdie
    1. Re:Real history. by Tribbin · · Score: 5, Funny

      *BASH*

      --
      If you mod this up, your slashdot background will turn into a beautiful sunset!
    2. Re:Real history. by girlintraining · · Score: 5, Funny

      tcsh, tcsh, tcsh. -Mom

      --
      #fuckbeta #iamslashdot #dicemustdie
    3. Re:Real history. by Naatach · · Score: 4, Funny

      *BASH*

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

      --
      There may be no "I" in team, but there's also no "F" in way.
    4. Re:Real history. by sortius_nod · · Score: 4, Funny

      Shell To Frustrate Users?

    5. Re:Real history. by Brad+Eleven · · Score: 2, Interesting

      P1: I wrote my first /bin/sh script on 9/10/1984
      P2: I'm still in touch with the other intern from that phase, who calls me and asks things like, "Is it 2>&1 or 2&>1? I never can remember..."
      C: Long term usage does not imply expertise.

      I like to think I'm pretty good, but I still review Csh Programming Considered Harmful for more esoteric usage of /bin/sh, when I have only that old tool available.

      --
      "Press to test."
      (click)
      "Release to detonate."
  3. PowerShell by Anonymous Coward · · Score: 4, Insightful

    Welcome to 1975, Microsoft.

    1. Re:PowerShell by CannonballHead · · Score: 5, Insightful

      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. :)

    2. Re:PowerShell by iminplaya · · Score: 2, Interesting

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

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

      --
      What?
    3. Re:PowerShell by CannonballHead · · Score: 3, Insightful

      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...)

    4. Re:PowerShell by qazwart · · Score: 2, Interesting

      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.

    5. Re:PowerShell by Hatta · · Score: 2, Insightful

      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.

      --
      Give me Classic Slashdot or give me death!
    6. Re:PowerShell by Hatta · · Score: 2, Insightful

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

      --
      Give me Classic Slashdot or give me death!
    7. Re:PowerShell by Tetsujin · · Score: 4, Insightful

      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.

      --
      Bow-ties are cool.
    8. Re:PowerShell by m.ducharme · · Score: 3, Funny

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

      --
      Rule of Slashdot #0: You and people like you are not representative of the larger population. - A.C.
    9. Re:PowerShell by Anonymous Coward · · Score: 2, Insightful

      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.

      Like a Unix user would be calling Perl or Python?

      The nice thing about Unix isn't about the shell, or the utilities (awk, sed, etc.), or the scripting languages: it's the fact that they can be all link together via pipes. As long as you move your data around as text, you can send it to anything on a Unix system.

    10. Re:PowerShell by unitron · · Score: 3, Funny

      Imagine the noise of a beowulf cluster of washing machines

      They're called laundromats.

      --

      I see even classic Slashdot is now pretty much unusable on dial up anymore.

    11. Re:PowerShell by cptnapalm · · Score: 4, Funny

      I've heard of those... they process threads there, don't they?

  4. Greenspun's Tenth Rule by Sir+Groane · · Score: 5, Funny

    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"

    1. Re:Greenspun's Tenth Rule by Sir+Groane · · Score: 5, Informative

      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.

    2. Re:Greenspun's Tenth Rule by RAMMS+EIN · · Score: 3, Insightful

      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.

      --
      Please correct me if I got my facts wrong.
    3. Re:Greenspun's Tenth Rule by overlordofmu · · Score: 2, Funny

      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!?!?

    4. Re:Greenspun's Tenth Rule by Hatta · · Score: 4, Funny

      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.

      --
      Give me Classic Slashdot or give me death!
  5. Sh? by janeuner · · Score: 5, Funny

    $ Sh
    sh: Sh: command not found

  6. perl by goombah99 · · Score: 2, Interesting

    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?

    --
    Some drink at the fountain of knowledge. Others just gargle.
    1. Re:perl by Sir+Groane · · Score: 2, Insightful

      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...

    2. Re:perl by goombah99 · · Score: 2, Insightful

      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.

      --
      Some drink at the fountain of knowledge. Others just gargle.
    3. Re:perl by module0000 · · Score: 2, Interesting

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

      --
      Trackball users will be first against the wall.
    4. Re:perl by goombah99 · · Score: 2, Informative

      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.>

      --
      Some drink at the fountain of knowledge. Others just gargle.
    5. Re:perl by ceswiedler · · Score: 3, Interesting

      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.

    6. Re:perl by frenchbedroom · · Score: 2, Informative

      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 ? :)

    7. Re:perl by Ex-Linux-Fanboy · · Score: 2, Insightful

      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. 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.

    8. Re:perl by goombah99 · · Score: 2, Insightful

      Okay now suppose you wanted to perhaps have an exception test for the killall or the askmara. Or suppose you wanted to have a time-out if they never returned. Finally assume you wanted to log the result of the action. Maybe you want to use a command line variable to supply say a password and the number of retries.

      Yes you could do all that in shell script. it simply is easier in perl.

      your assurance that your perlscripts will run is that the first line of the perl program specifies which perl interpreter to use. if it requires 5.6 you tell it to use 5.6

      --
      Some drink at the fountain of knowledge. Others just gargle.
  7. Do windows users need a shell? by Savage-Rabbit · · Score: 4, Insightful

    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.

    --
    Only to idiots, are orders laws.
    -- Henning von Tresckow
    1. Re:Do windows users need a shell? by TheLink · · Score: 5, Interesting

      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

      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 :).

      --
    2. Re:Do windows users need a shell? by RAMMS+EIN · · Score: 2, Informative

      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.

      --
      Please correct me if I got my facts wrong.
  8. Compiler research by TinBromide · · Score: 2, Interesting

    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.

    --
    Is it sad that I am more likely to recognize you and your posts by your sig than your name or UID?
  9. This inspired me to write a tiny *NIX shell by Ex-Linux-Fanboy · · Score: 2, Interesting

    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 guys are looking to rewrite their *NIX shell to be more modular; this code would be a good starting point.

    - Sam

  10. Now there's a man with hair on his chest by TennesseeVic · · Score: 5, Funny

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

    1. Re:Now there's a man with hair on his chest by garyebickford · · Score: 4, Insightful

      And this speaks to why IMHO it was unfair (besides being stupid) to change the rules on software patents in 1986. Prior to that time, the huge amount of seminal, fundamental, wonderful work (by geniuses and people much smarter than me) in software and systems could not be patented, so it was either secret (for a while) or open. All those giants back then had no opportunity to set up a licensing toll bridge. And now, an infinite regression of trivialities are patented.

      Imagine what progress in computing would have been if Alan Kay had been able to patent windowing GUIs, or if object-oriented programming had been patented, or paged virtual memory, timesharing, CDMA, TCP, IP, programming macros, relocatable code linkers, electronic mail, image morphing, most computer graphics and imaging techniques, ... the list goes on.

      Some of the core ideas incorporated by Berners-Lee in his WWW creation could have been patented either by him, or by NeXT Computer before he had a chance. And then where would we be?

      Hell, I personally could have gotten patents on client-server image processing nets, steganography, SAN, image paging and pre-fetch, pan-and-zoom image and map display, a whole raft of specialize raster-op (bitblit) functions, physical mapping of image files onto disk sectors, street-address interpolation, for geolocation. And that's just a sample of the bigger stuff I was involved in from 1983-1985. Oh yeah - a collaborative sketchpad over ethernet, in 1982!

      At the time (early and mid 1980's) NONE of this was patentable. And now people are getting held up for $millions for stuff we didn't even bother to document or publish, because it was so trivial. And (just for perspective) I was just a regular schmoe - not one of the lights of programming.

      rant, rant, rant... I totally agree with what you said :) I was not and am not worthy either. And certainly neither are the market- and legal-droid twits at Amazon and Microsoft and elsewhere who browbeat the software writers into signing off on the post-placental detritus that modern software patents are and will always be.

      --
      It's easier to be a result of the past, but more fun to be a cause of the future! http://www.spacefinancegroup.com/
  11. Windows Script Host by tepples · · Score: 2, Informative

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

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

  12. C# and Java vs. the "P" languages by tepples · · Score: 3, Insightful

    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.

  13. The Unix Shell and Scripting Languages by Tetsujin · · Score: 3, Interesting

    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.

    --
    Bow-ties are cool.
  14. Yes, PowerShell by benjymouse · · Score: 4, Informative

    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()
    --
    Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
    1. Re:Yes, PowerShell by buchner.johannes · · Score: 3, Insightful

      We should make a coreutils package that outputs XML, JSON or similar, so we don't need stupid cut/grep/head tricks anymore and can, for example, directly access a column, or sum stuff up.

      The last command in the pipe chain would output in a user-readable format.

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
  15. PowerShell and critique of the Unix shell by Tetsujin · · Score: 4, Insightful

    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.

    Like a Unix user would be calling Perl or Python?

    Not quite... The shell user can call Perl or Python to access libraries or datatypes - but these concepts are meaningless within the framework of the shell itself. In Powershell, a commandlet returning an object yields something you can work with in the shell - see what object methods or data fields it provides, run methods, pass the object to another commandlet, etc.

    Powershell provides a powerful set of baseline assumptions for the format of data over the pipe - and so both the shell itself and commandlets running in the shell can take advantage of these assumptions. In Unix, the typical approach is to "roll your own format" each time - which is trivial for trivial problems, but substantially harder as you start worrying about questions like, what happens when my data fields contain the character I want to use as a delimiter?

    This is further complicated by the fact that existing Unix programs, outputting text, typically format that text for human consumption. The exact format of a program's input or output may change from release to release with no coherent strategy for establishing any kind of compatibility. In comparison, in Powershell a piece of data passed from one process to another has a predictable underlying structure - it's formatted for consumption by another process rather than for display at the terminal. But since the shell itself also recognizes this format, it has a reasonable default behavior for displaying a command output - or if necessary you can pipe through a command whose job is to make nicely formatted output of selected columns of another program's result.

    Now, what are the benefits of serializing to text format? You can look at it, printed on-screen, and know what it represents and how to parse it, right? The problem is this becomes less and less true as the data format becomes more intricate, more comprehensive - which is bound to happen as you start doing things like handling more complex problems, implementing data formats that account for future upgrades, and so on. The strength of PowerShell's approach (the same approach, basically, as you'd find in any other capable, interactive programming language) is that it knows enough about the format of data it handles that it can make that format easy to view and work with - easier, in fact, than plain text, because you see a representation of the data's meaning rather than of its underlying structure.

    As another example, consider what it would take to provide any kind of higher-order programming in the shell. There's a limited degree of this available already, of course: if you want to pass a "function" to something, you form it into a shell script, put it in a directory somewhere, and provide the full pathname to that function as an argument to your higher-order program - which will then use something like "system()", "popen()" or "exec()" to invoke it.

    Now, what if you want to include a set of data, representing the state of an "object" with that "function"? You can do that, too - you can write out a data file representing the current state, and pass both the script and the data file names to your higher-order program. Or you could have a program running in the background, communicating via some form of IPC - maybe over a named pipe or listening to a particular network socket or hosted by an object broker, and pass the necessary reference to the higher-order function. Or, about the nicest you can manage in the shell (though decidedly not a clean solution IMO) - start a process in the background which maintains the state you're working with, and have a second executable which communicates with the background process, passing on commands and bringing back results.

    The problem is, none of those me

    --
    Bow-ties are cool.
  16. Why so verbose? by benjymouse · · Score: 2, Informative

    when

    ls -r | ?{-not($_|ls)}

    would suffice?

    Explanation:

    1) list all items recursively from the current location

    2) filter only those items where ls returns an empty set.

    Btw, the objects returned from that command are *still* DirectoryInfo objects, allowing even further operations or property accesses.

    Also, this command will work the same even if the "current location" is a node in the registry, the certificate store, the credentials store, a group in active directory etc etc.

    In other words if you change the location to an organisational unit in AD, the exact same command will find empty sub-containers.

    --
    Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
  17. Cambridge Phoenix system by Alain+Williams · · Score: 2, Interesting

    Steve was at Cambridge University (the real one in the UK), he would have used the Phoenix System, this was an on line system with a command programming language. I cut my scripting teeth on this in the 1970s. It did variable substitution and had here documents.

  18. Command substitution a "new idea?" by dpbsmith · · Score: 2, Informative

    "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."

    Surely this feature was present in Calvin Mooer's TRAC, circa 1964 or thereabouts. I've forgotten the distinction between expanded macros by means of single or double slashes, but I believe one or the other of them substituted the macro expansion back in the stream for further processing. My recollection is that it was fundamental to the way TRAC was used in practice. My recollection is also that TRAC was moderately well-known in the community at the time, so the idea was "in the air."

    I believe it also existed in a host of "macro" capabilities in assembly languages... familiar to me in MIDAS, an assembly language for the PDP-1 circa 1965 or so. MIDAS survived into the PDP-6 and PDP-10, may have been developed earlier for the TX-0, and I think may have been patterned on advanced macro assemblers for the IBM 709.

  19. My /bin/sh rules by SpaghettiPattern · · Score: 2, Informative
    As an IT pro, I recognize the significance of /bin/sh and I am very grateful for to Steve Bourne for his creation. It's the smallest (that's a good thing), consistent and standardized command set for setting up environments to run programs.

    My scripting rules on UNIX like systems:
    • Anything that can be done in /bin/sh I DO in /bin/sh.
    • Anything slightly more complex I do in Perl.
    • Anything truly complex I write in Java.
    • For writing scripts I NEVER, EVER use slightly enhanced shells like (t)csh (know for having bugs), ksh (used to be proprietary) or bash (too many features I DON'T want for simple scripts).
    • People that resort to slightly enhanced shells for scripting qualify themselves as being ... let's say ... inexperienced.
    • It pisses me off when I have to look up special csh, ksh or bash constructs in order to understand scripts.
    • Fancy variables? Reconsider or write Perl.
    • Fancy condition checking? Reconsider or write Perl.
    • Fancy arithmetic? Reconsider or write Perl.
    • Fancy system access (e.g. ipc)? Write Perl.
    • However, my favorite INTERACTIVE shell is bash. It gets the /bin/sh syntax and offers stuff that makes you extremely quick when working interactively.
    --

    I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)