Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
Resources for portable shell programming

I want to write a shell script that is intended for further distribution. So I'd like to write it in a way that is as portable as possible; by which I mean that it shouldn't rely on any fancy stuff that is only available in the particular flavour of qzdfsh that I happen to have installed on my own machine. The script will not be very complicated (the worst it will have to do is strip file extensions and test returns from programs).

Where can I find out what stuff is supported in (almost) all shells?

(I'm particularly aware of the fact that /bin/sh is often symlinked to "something else" so simply testing that it works with /bin/sh seems a dubious strategy.)

share|improve this question

marked as duplicate by Gilles, phunehehe, Caleb, Michael Mrozek Aug 3 '11 at 18:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
@Philomath: Yup, looks like it to me. I'll take a look at the resources in that one. (Needless to say, I didn't find that via searching otherwise I wouldn't have asked this one ...). Feel free to close-as-duplicate. If I don't find what I'm looking for, I'll ask a more focussed question. Thanks. –  Loop Space Jul 29 '11 at 10:16

1 Answer 1

While /bin/sh might be a symlink to bash, it still makes a difference. Bash looks how it is invoked, and if invoked as 'sh', either explicitly, or by symlink, or by a parameter/switch, bash will try to act in POSIX mode.

So using a shebang

#/bin/sh

and starting it as ./script or sh .script should be sufficient.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.