January 25, 2011
Jacob Carlborg Wrote:

> Yeah, I guess you're right, didn't think there were a lot people who used other shells. Since I almost know nothing about shell scripting and even less about non-bourne shells, will it be possible to port to other shells? How much do they differ?
> 
> -- 
> /Jacob Carlborg

To add to Lutger's message. I believe it is sh that is required by all Posix systems, or at least an equivalent. Similarly I think vi is also a requirement.

In all likelyhood you probably used a Bash specific feature, but usually everyone has bash even if they use zsh... Though Ubuntu/Debian has started pointing /bin/sh to dash which is complaint with posix...
January 26, 2011
On 2011-01-25 23:30, "Jérôme M. Berger" wrote:
> Jacob Carlborg wrote:
>> On 2011-01-25 20:33, "Jérôme M. Berger" wrote:
>>> Jacob Carlborg wrote:
>>>> Platforms: currently only Posix
>>>>
>>>      Nitpick: it is more restricted than that. Platform is currently
>>> only posix *with bash shell*. A lot of people use other shells,
>>> including non-Bourne shells (most frequent are zsh, ksh and tcsh).
>>>
>>>          Jerome
>>
>> Yeah, I guess you're right, didn't think there were a lot people who
>> used other shells. Since I almost know nothing about shell scripting and
>> even less about non-bourne shells, will it be possible to port to other
>> shells? How much do they differ?
>>
> 	Well, for other Bourne shells (like zsh or ksh), it will probably
> mostly be a question of putting the initialization code in the right
> file (i.e. .zshrc or .kshrc). Other than that, unless you are doing
> something pretty fancy, the same code should work.
>
> 	For C-shells (like tcsh) the syntax is pretty different, so it will
> probably require more changes. However, it has been a while since I
> last used tcsh, so I cannot tell you how much work it would be.
>
> 		Jerome

Ok.

-- 
/Jacob Carlborg
January 26, 2011
On 2011-01-25 23:59, Jesse Phillips wrote:
> Jacob Carlborg Wrote:
>
>> Yeah, I guess you're right, didn't think there were a lot people who
>> used other shells. Since I almost know nothing about shell scripting and
>> even less about non-bourne shells, will it be possible to port to other
>> shells? How much do they differ?
>>
>> --
>> /Jacob Carlborg
>
> To add to Lutger's message. I believe it is sh that is required by all Posix systems, or at least an equivalent. Similarly I think vi is also a requirement.
>
> In all likelyhood you probably used a Bash specific feature, but usually everyone has bash even if they use zsh... Though Ubuntu/Debian has started pointing /bin/sh to dash which is complaint with posix...

Ok. I'll see I can use only sh.

-- 
/Jacob Carlborg
January 26, 2011
On Wed, 26 Jan 2011 03:36:24 -0500, Jacob Carlborg <doob@me.com> wrote:

> On 2011-01-25 23:59, Jesse Phillips wrote:
>> Jacob Carlborg Wrote:
>>
>>> Yeah, I guess you're right, didn't think there were a lot people who
>>> used other shells. Since I almost know nothing about shell scripting and
>>> even less about non-bourne shells, will it be possible to port to other
>>> shells? How much do they differ?
>>>
>>> --
>>> /Jacob Carlborg
>>
>> To add to Lutger's message. I believe it is sh that is required by all Posix systems, or at least an equivalent. Similarly I think vi is also a requirement.
>>
>> In all likelyhood you probably used a Bash specific feature, but usually everyone has bash even if they use zsh... Though Ubuntu/Debian has started pointing /bin/sh to dash which is complaint with posix...
>
> Ok. I'll see I can use only sh.

FWIW, /bin/sh is usually a symlink to bash, and it makes bash behave like the original Bourne Shell.

I typically find /bin/sh features to be enough for implementing most scripts.

A good reference (if you don't have it) is Unix in a nutshell, probably my most used textbook.

-Steve
January 26, 2011
On Wed, 2011-01-26 at 08:58 -0500, Steven Schveighoffer wrote: [ . . . ]
> FWIW, /bin/sh is usually a symlink to bash, and it makes bash behave like the original Bourne Shell.

For some definition of "usually".  On Debian and Ubuntu /bin/sh is a symbolic link to dash not bash.

> I typically find /bin/sh features to be enough for implementing most scripts.

And the only guaranteed portable script -- assuming Windows without Cygwin or MSYS is excluded !

[ . . . ]
-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@russel.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


January 26, 2011
On Wed, 26 Jan 2011 10:50:20 -0500, Russel Winder <russel@russel.org.uk> wrote:

> On Wed, 2011-01-26 at 08:58 -0500, Steven Schveighoffer wrote:
> [ . . . ]
>> FWIW, /bin/sh is usually a symlink to bash, and it makes bash behave like
>> the original Bourne Shell.
>
> For some definition of "usually".  On Debian and Ubuntu /bin/sh is a
> symbolic link to dash not bash.

On my ubuntu system too -- to my surprise ;)

On my fedora system I think it was symlinked to bash.

Either way, the actual "bourne shell" is rarely installed on Linux, it's usually another shell that mimics the features.

-Steve
January 26, 2011
Am 26.01.2011 09:36, schrieb Jacob Carlborg:
> On 2011-01-25 23:59, Jesse Phillips wrote:
>> Jacob Carlborg Wrote:
>>
>>> Yeah, I guess you're right, didn't think there were a lot people who used other shells. Since I almost know nothing about shell scripting and even less about non-bourne shells, will it be possible to port to other shells? How much do they differ?
>>>
>>> -- 
>>> /Jacob Carlborg
>>
>> To add to Lutger's message. I believe it is sh that is required by all Posix systems, or at least an equivalent. Similarly I think vi is also a requirement.
>>
>> In all likelyhood you probably used a Bash specific feature, but usually everyone has bash even if they use zsh... Though Ubuntu/Debian has started pointing /bin/sh to dash which is complaint with posix...
> 
> Ok. I'll see I can use only sh.
> 

Debian (and probably ubuntu as well) has a package called "devscripts" which
contains a handy tool called "checkbashisms". This tool tells you if your script
uses bash-specific stuff and often even suggests a more portable alternative.
I haven't checked DVM yet, but if you want to have stuff done one login, put it
into ~/.profile instead of ~/.bashrc - this should be executed by all POSIX
compliant shells I think.

Cheers,
- Daniel
January 26, 2011
Steven Schveighoffer Wrote:

> On my ubuntu system too -- to my surprise ;)

It is a new thing they did, about a release or two ago. The reason was because /bin/sh pointed to bash and _did not_ adhere to the sh standard.
January 26, 2011
On 2011-01-26, Jesse Phillips <jessekphillips+D@gmail.com> wrote:
> Steven Schveighoffer Wrote:
>
>> On my ubuntu system too -- to my surprise ;)
>
> It is a new thing they did, about a release or two ago. The reason was because /bin/sh pointed to bash and _did not_ adhere to the sh standard.

It was a system speed enhancement.
Much of the bootup speed gain was due to switching to dash.
bash is slow.

bash adhere's to sh standards is just fine except that it won't flag extensions, so you can still end up with bashisms in your shell script. I've never had any issues w/bash.

I write shell scripts that run in bash2, bash3, bash4, ash, dash, ksh88, ksh93, mksh, SunOS sh, Tru64 sh, AIX sh, HP-UX sh.
January 26, 2011
Jacob Carlborg wrote:
> On 2011-01-25 23:59, Jesse Phillips wrote:
>> Jacob Carlborg Wrote:
>>
>>> Yeah, I guess you're right, didn't think there were a lot people who used other shells. Since I almost know nothing about shell scripting and even less about non-bourne shells, will it be possible to port to other shells? How much do they differ?
>>>
>>> -- 
>>> /Jacob Carlborg
>>
>> To add to Lutger's message. I believe it is sh that is required by all Posix systems, or at least an equivalent. Similarly I think vi is also a requirement.
>>
>> In all likelyhood you probably used a Bash specific feature, but usually everyone has bash even if they use zsh... Though Ubuntu/Debian has started pointing /bin/sh to dash which is complaint with posix...
> 
> Ok. I'll see I can use only sh.
> 
	You cannot. You need to modify the environment for the current
shell, which is the shell that the user is currently using (no
matter what else may or may not be installed on the system). This
has two consequences:

- You need to have some code that is run when the shell starts (i.e. from .bashrc, .zshrc or .kshrc). That code will define the proper aliases and/or functions (at the time being, this is mostly the "dvm" function in "dvm.sh" (*)). This can be accomplished by having a different version of this file for each shell;

- You need to generate the contents of $dvm_result_path in a format that the shell will understand. The easiest way to do that is probably to define a few extra functions in "dvm.sh" to enable setting environment variables in a portable way and handle additional requirements (like "builtin hash -r" which is definitely a bash-ism). Then generate the $dvm_result_path using these functions instead of the normal shell syntax.

		Jerome

(*) BTW, I hope you do not add the full contents of dvm.sh nor a "source dvm.sh" in .bashrc the way it is now. Otherwise, a misconfiguration may prevent the user from starting a shell!

-- 
mailto:jeberger@free.fr
http://jeberger.free.fr
Jabber: jeberger@jabber.fr