Hacker News new | past | comments | ask | show | jobs | submit login

It doesn't matter what people think, what matters is that the code is portable. Isn't it better that the program JustWork(SM) unmodified on all platforms without having to worry about whether the shell is POSIX-compliant?

Up until the latest Solaris 10 patches, /bin/sh and /sbin/sh did not implement set -e, because on Solaris /bin/sh is the real McCoy - Steven Bourne's shell from 1972 - 1977. There is a fully POSIX compliant /usr/xpg4/bin/sh, but only Solaris experts know that the /usr/xpg4 directory exists and what is in it; 99.99% of the people out there won't have it before /bin or /usr/bin in their PATH.

Portability should never be traded for convenience, because when one does that, one forces "the next guy" to waste his time fixing one's code. That's just wrong. I've had so much of my life wasted by GNU/Linux "bashisms" which were completely unnecessary. I resent that deeply. That's my life I could have spent in more productive and fulfilling ways, rather than fixing what should not have been broken to begin with.

If you want to write portable shell programs, write them in ksh and then you won't have to worry about POSIX or non-POSIX.




> Up until the latest Solaris 10 patches, /bin/sh and /sbin/sh did not implement set -e, because on Solaris /bin/sh is the real McCoy - Steven Bourne's shell from 1972 - 1977.

There's been a conformant POSIX shell on Solaris since 1995.

/bin/sh has been conformant to this since 2007 or so.

It is 2019. When should we be allowed to use it?

POSIX is the standard for Unix portability and has been for the last 2 decades. System V never was.

> Portability should never be traded for convenience, because when one does that, one forces "the next guy" to waste his time fixing one's code. That's just wrong. I've had so much of my life wasted by GNU/Linux "bashisms"

"set -e" is not a bashism. The errflag was there from nearly the beginning. By the early 1979 BSD 3 development tree, it could be triggered by 'set -e'. When the POSIX standards committee decided to iron out differences between the BSD and SystemV branches of the Unix Family tree, they decided it was worth keeping, and over the next few years everyone conformed.

> Portability should never be traded for convenience, because when one does that, one forces "the next guy" to waste his time fixing one's code. That's just wrong. I've had so much of my life wasted by GNU/Linux "bashisms" which were completely unnecessary. I resent that deeply. That's my life I could have spent in more productive and fulfilling ways, rather than fixing what should not have been broken to begin with.

There's also things that are good for everyone else's productivity-- by e.g. not catering to someone who is stuck 18-40 years in the past.


> because on Solaris /bin/sh is the real McCoy - Steven Bourne's shell from 1972 - 1977

Wow-- I hadn't realized just how wrong your argument was! Bourne's shell from the outset supported set -e!

From Bourne's "An Introduction to the Unix Shell", ~1977-1978 (converted to HTML at http://porkmail.org/era/unix/shell.html )

> The shell flag -e causes the shell to terminate if any error is detected.

and the document goes on to state that you can use 'set' to set shell flags.

It's in the V7 source, too:

  CHAR    flagchar[] = {
        'x',    'n',    'v',    't',    's',    'i',    'e',    'r',    'k',    'u',    0
  };
  INT     flagval[]  = {
          execpr, noexec, readpr, oneflg, stdflg, intflg, errflg, rshflg, 
  keyflg, setflg, 0
  };
Along with a proper call to options() in the set builtin.

If the basis of your whole argument is history, you're complaining about something that would have worked on V7 or 3BSD. :D Apparently they are "too new."

edit: Running V7 on a PDP-11 emulator has the anticipated results:

  boot
  Boot
  : hp(0,0)unix
  mem = 2020544
  # RESTRICTED RIGHTS: USE, DUPLICATION, OR DISCLOSURE
  IS SUBJECT TO RESTRICTIONS STATED IN YOUR CONTRACT WITH
  WESTERN ELECTRIC COMPANY, INC.
  WED DEC 31 19:15:00 EST 1969
                                                                                                                                                                                                               
  login: root
  Password:
  You have mail.
  #
  #
  # set -e
  # false
  login:


>Up until the latest Solaris 10 patches

You speak in absolutes.

Very dated absolutes as well.

You might want to think about that.

Solaris 10 release date: January 2005.


Turns out they're absolutely wrong absolutes, too, since Bourne's shell, as it shipped in V7, supported set -e.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: