User: Password:
|
|
Subscribe / Log in / New account

Shell programming

Shell programming

Posted Dec 8, 2012 1:35 UTC (Sat) by Cyberax (✭ supporter ✭, #52523)
In reply to: Shell programming by dlang
Parent article: Quotes of the week

HAhahahahadhahadkLOLOLL.

I've recently spent 5 hours rewriting old scripts from a long ago retired Sun box. Searching old manuals to understand what non-standard command line options do is such a great way to spend time. Especially when it's not possible to simply run them.


(Log in to post comments)

Shell programming

Posted Dec 8, 2012 2:05 UTC (Sat) by sitaram (guest, #5959) [Link]

That has nothing to do with shell per se. It's just non-open source versus open source. If they were open source you'd still be able to compile and run them.

As for non-standard options, I suspect most of the Sun utilities would be closer to BSD.

Shell programming

Posted Dec 8, 2012 2:11 UTC (Sat) by Cyberax (✭ supporter ✭, #52523) [Link]

Even if they were OpenSource (which they are), you'd need to compile 20-year old crufty C code and quite likely newer GCC versions won't do the trick. Waaaaay too much work.

On the other hand, I've ported 15-year old Python scripts without much problems. There were several non-backward-compatible changes in Python since then, but they are fairly minor.

Shell programming

Posted Dec 8, 2012 6:53 UTC (Sat) by mathstuf (subscriber, #69389) [Link]

Some anecdara:

For Python, one I hit today was to change "except BaseException as e:" to "except BaseException: e = sys.exc_info()[0]" to support 2.4 through 3.2 in the same script. A little annoying, but not as pretty as either just-one-way canonical syntax.

As for shell, we found out that BSD sed and GNU sed don't support compatible -i flags. BSD requires a suffix, GNU requires there be no space if one is given, which BSD rejects. Using manual .bak files feels worse than either by a long shot. I think the call has been replaced by awk instead now.

In my experience, GNUisms tend to be harder to work around than Python incompatibilities. That's why I try to avoid them in my shell scripts. Unfortunately, sed -i is very convenient and sponge just isn't common enough, but this is slowly being trained out of my fingers when I'm in "portable" mode (I use every trick I can at the prompt, just not when writing .sh files).

Commands on an old Sun box

Posted Dec 10, 2012 7:19 UTC (Mon) by jrn (subscriber, #64214) [Link]

Have you looked at the heirloom toolset (http://heirloom.sourceforge.net/)?

Commands on an old Sun box

Posted Dec 10, 2012 14:17 UTC (Mon) by Cyberax (✭ supporter ✭, #52523) [Link]

Nope (I didn't know about it).

In any case, I was interested in a rewrite in a sane language, not just running these scripts.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds