why Unix?

Steven Schveighoffer schveiguy at yahoo.com
Tue Apr 7 12:30:22 PDT 2009


On Tue, 07 Apr 2009 15:03:54 -0400, grauzone <none at example.net> wrote:

> Steven Schveighoffer wrote:
>> On Tue, 07 Apr 2009 14:35:04 -0400, grauzone <none at example.net> wrote:
>>
>>>> But shell scripting in itself is so powerful for this kind of stuff.   
>>>> I've written lots of little scripts to do fantastic things that on  
>>>> Windows would be so painful (without cygwin of course).  Like  
>>>> renaming all files of a certain type to something else, or copying  
>>>> select files to another directory.
>>>
>>> Now wouldn't that be much more powerful to use an actual programming  
>>> language for this, instead of bash? I claim with something like  
>>> python, bash doesn't really have any right to exist anymore.
>>  I can log into ANY Linux, Solaris, BSD, OSX, etc system and have a  
>> reasonable /bin/sh that allows at least bourne shell functionality.   
>> The same can't be said for almost any other scripting language you can  
>> throw at me.
>
> Sure, /bin/sh is the least common denominator. But is there a UNIX that  
> can't run python?

I would guess there isn't. But when someone says, "hey, I need a script  
that does this," I don't ever have to say "oh, you don't have /bin/sh  
installed?  Sorry, can't help you."

>> Of course, aside from that, I hate python syntax...  And can python be  
>> used as a user shell?
>
> Don't tell me you hate it more than the clusterfuck that is sh syntax?  
> Reading or writing sh scripts always feels like screwing in bolts into  
> my head.

Yes, I hate it more.  sh is a simple syntax (described in 34 pages, most  
of which are builtin functions, of my Unix in a Nutshell book), and has no  
standard library.  All the "library" is are standard unix commands.  I had  
to fix some shit in the live CD creator script written in python on  
Fedora.  It took me a long, long time to figure out what it was doing.   
Does it *really* require you to type self every time you want to access a  
member?  And what's up with all the freakin underscores?  You consider  
that a good programming syntax?  The syntax of python is horrendous.  The  
only thing I can think of that's worse is VBScript.  It might be a good  
language, but I can't get past the syntax.

> And regarding using it as an user shell: there's an interactive command  
> line interpreter.

if you type ls, does it work, or do you have to type __run__("ls") or  
whatever?

>> How would you do the same thing in python?  Would it be any clearer or  
>> shorter?  Probably not.
>
> Not in all cases. But in general, I'd expect it to be clearer. Python is  
> just more similar to normal programming than sh, which is why I'd prefer  
> it.

You thought my script was unclear?  I thought you could know exactly what  
it's doing without even knowing sh syntax.  Maybe the most confusing part  
was the 'fi' denoting an end of an if statement.

Prove me wrong, show me a python script that does the same thing, and  
we'll see if it's clearer.

>
> sh scripts aren't very reliable either. I remember that script that  
> invoked another program. That other program produced some warning, and  
> the script interpreted it as normal output.

Oh yeah, that *must* have been the scripting language's fault.  I have  
bugs in my D programs too, must be because D sucks?

> And escaping. I don't think there are many scripts that still work  
> correctly if they encounter "strange" filenames, like filenames with  
> spaces, special characters, or even line breaks. Yes, \n is a valid  
> character in UNIX filenames.

That is what single quoting is for.  'xy
*$123' is that string exactly, no interpretation of any special characters.

Want to know a good trick to play on a unix newbie?  Make a file in their  
home directory called *

touch '*'

Not knowing what it is, they try to remove it:

rm *

hilarity ensues :)

>
>> I'm sure some would argue that there is no point for python if you can  
>> run perl...
>
> Perl doesn't have any right to exist either. It has the same brainfuck  
> quirks like sh. For example, defining magical global variables and such.  
> And clusterfuck syntax. It even has a reputation as read-only language.
>
> For that matter, any language better than sh or Perl would be better for  
> a shell.

So basically, you don't like other scripting languages so they don't have  
a right to exist?  Interesting point of view.

-Steve



More information about the Digitalmars-d mailing list