Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best (portable and maintanable) Shell Scripting language today?

I know this question has kind-a started "religious" wars in past and there might not be one correct answer. But after working with ksh and csh for last 3-4 years and going through the pain of porting from one to another or applying a common piece of logic to multiple versions (read as legacy code), if I am writing a new script, I would go for ksh, but out of compulsion rather than choice. Is there a better option other than ksh/csh? Also something that is portable across Unixes (Solaris/HP/IBM/FreeBSD) and Linux (and if I am not asking too much or it if does make sense all Linux flavors)

Waiting for suggestions ...

Peace :) Devang Kamdar

like image 254
Devang Kamdar Avatar asked May 19 '09 09:05

Devang Kamdar


2 Answers

I would suggest plain old sh, which is available everywhere.

Also, it is worth noting that portability involves not only shell but also other commands used in a script such as awk, grep, ps or echo.

like image 155
mouviciel Avatar answered Sep 28 '22 07:09

mouviciel


If you really want it to be portable (I don't know that any shell-script is maintainable), I would specify #!/bin/sh and test with dash and if possible other shells.

like image 38
Matthew Flaschen Avatar answered Sep 28 '22 08:09

Matthew Flaschen