www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - DVM - D Version Manager

reply Jacob Carlborg <doob me.com> writes:
I've created a tool that installs and manages D compilers and different 
versions.

Description:

DVM allows you to easily download and install D compilers and manage 
different versions of the compilers. When you switch D compiler with the 
"use" command the compiler will only be available in the current shell. 
This allows you to have one version of the compiler in one shell and 
another version in another shell. For example, have a D1 version in one 
shell and a D2 version in another.

The tool is available at bitbucket: https://bitbucket.org/doob/dvm
The wiki contains installation and usage instructions: 
https://bitbucket.org/doob/dvm/wiki/Home

Platforms: currently only Posix

-- 
/Jacob Carlborg
Jan 24 2011
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Jacob Carlborg" <doob me.com> wrote in message 
news:ihkvrr$1l02$1 digitalmars.com...
 I've created a tool that installs and manages D compilers and different 
 versions.

 Description:

 DVM allows you to easily download and install D compilers and manage 
 different versions of the compilers. When you switch D compiler with the 
 "use" command the compiler will only be available in the current shell. 
 This allows you to have one version of the compiler in one shell and 
 another version in another shell. For example, have a D1 version in one 
 shell and a D2 version in another.

 The tool is available at bitbucket: https://bitbucket.org/doob/dvm
 The wiki contains installation and usage instructions: 
 https://bitbucket.org/doob/dvm/wiki/Home

 Platforms: currently only Posix

Yay! That sounds great! This is the second thing this week that I'd been intending to do and have been thrilled to be beaten to the punch :) You can bet I'll take a crack at porting it to windows...uhhh...assuming I can find the time...heh ;)
Jan 24 2011
next sibling parent reply Don <nospam nospam.com> writes:
Nick Sabalausky wrote:
 "Jacob Carlborg" <doob me.com> wrote in message 
 news:ihkvrr$1l02$1 digitalmars.com...
 I've created a tool that installs and manages D compilers and different 
 versions.

 Description:

 DVM allows you to easily download and install D compilers and manage 
 different versions of the compilers. When you switch D compiler with the 
 "use" command the compiler will only be available in the current shell. 
 This allows you to have one version of the compiler in one shell and 
 another version in another shell. For example, have a D1 version in one 
 shell and a D2 version in another.

 The tool is available at bitbucket: https://bitbucket.org/doob/dvm
 The wiki contains installation and usage instructions: 
 https://bitbucket.org/doob/dvm/wiki/Home

 Platforms: currently only Posix

Yay! That sounds great! This is the second thing this week that I'd been intending to do and have been thrilled to be beaten to the punch :) You can bet I'll take a crack at porting it to windows...uhhh...assuming I can find the time...heh ;)

FWIW, I just copy all the versions of dmd into olddmd/dmd2051, etc, and then use a trivial batch file. (Uses junction from sysinternals to make a symlink). --- junction c:\dmd c:\olddmd\dmd%1 > nul if not errorlevel 0 echo don't have version %1 --- eg, usedmd 2051
Jan 25 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-01-25 14:48, Steven Schveighoffer wrote:
 On Tue, 25 Jan 2011 08:32:42 -0500, Lars T. Kyllingstad
 <public kyllingen.nospamnet> wrote:


 Does it look in the executable directory on Linux too? If so, does that
 take precedence over /etc/dmd.conf and environment variables?

http://www.digitalmars.com/d/2.0/dmd-linux.html#dmd_conf -Steve

Oh, /etc/ will be last, nice. -- /Jacob Carlborg
Jan 25 2011
prev sibling next sibling parent "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
On Tue, 25 Jan 2011 09:14:06 +0100, Don wrote:

 Nick Sabalausky wrote:
 "Jacob Carlborg" <doob me.com> wrote in message
 news:ihkvrr$1l02$1 digitalmars.com...
 I've created a tool that installs and manages D compilers and
 different versions.

 Description:

 DVM allows you to easily download and install D compilers and manage
 different versions of the compilers. When you switch D compiler with
 the "use" command the compiler will only be available in the current
 shell. This allows you to have one version of the compiler in one
 shell and another version in another shell. For example, have a D1
 version in one shell and a D2 version in another.

 The tool is available at bitbucket: https://bitbucket.org/doob/dvm The
 wiki contains installation and usage instructions:
 https://bitbucket.org/doob/dvm/wiki/Home

 Platforms: currently only Posix

This is the second thing this week that I'd been intending to do and have been thrilled to be beaten to the punch :) You can bet I'll take a crack at porting it to windows...uhhh...assuming I can find the time...heh ;)

then use a trivial batch file. (Uses junction from sysinternals to make a symlink). --- junction c:\dmd c:\olddmd\dmd%1 > nul if not errorlevel 0 echo don't have version %1 --- eg, usedmd 2051

Won't the script have to somehow set the import and library paths as well, so that DMD finds its corresponding druntime/phobos versions? -Lars
Jan 25 2011
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2011-01-25 01:43, Nick Sabalausky wrote:
 "Jacob Carlborg"<doob me.com>  wrote in message
 news:ihkvrr$1l02$1 digitalmars.com...
 I've created a tool that installs and manages D compilers and different
 versions.

 Description:

 DVM allows you to easily download and install D compilers and manage
 different versions of the compilers. When you switch D compiler with the
 "use" command the compiler will only be available in the current shell.
 This allows you to have one version of the compiler in one shell and
 another version in another shell. For example, have a D1 version in one
 shell and a D2 version in another.

 The tool is available at bitbucket: https://bitbucket.org/doob/dvm
 The wiki contains installation and usage instructions:
 https://bitbucket.org/doob/dvm/wiki/Home

 Platforms: currently only Posix

Yay! That sounds great! This is the second thing this week that I'd been intending to do and have been thrilled to be beaten to the punch :) You can bet I'll take a crack at porting it to windows...uhhh...assuming I can find the time...heh ;)

The plan is to have a version for Windows, the D code is written with a Windows in mind. But the problem is the bash scripts, I'm not sure if a Windows version is possible. Bash scripting is vastly superior to batch scripting. For example, I don't know if there is any batch equivalent to the following in bash: * The "source" function/command * .bashrc/bash_profile In batch there is the "call" function but I don't know if it will retain any environment variables set by called the script. There exists a key (or what it's called) in the Windows register where you can add a path to a script that will be executed when the user logs in, opens cmd or something like that. -- /Jacob Carlborg
Jan 25 2011
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2011-01-25 12:58, Vladimir Panteleev wrote:
 On Tue, 25 Jan 2011 10:46:45 +0200, Jacob Carlborg <doob me.com> wrote:

 But the problem is the bash scripts, I'm not sure if a Windows version
 is possible.

For what it's worth, I'm a FAR Manager user, and I've written myself a FAR plugin to solve this problem (and for other toolkits too): http://blog.thecybershadow.net/2010/04/02/envman-far-plugin-to-manage-your-environment/

I'll have a look at that. -- /Jacob Carlborg
Jan 25 2011
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2011-01-25 12:58, Vladimir Panteleev wrote:
 On Tue, 25 Jan 2011 10:46:45 +0200, Jacob Carlborg <doob me.com> wrote:

 But the problem is the bash scripts, I'm not sure if a Windows version
 is possible.

For what it's worth, I'm a FAR Manager user, and I've written myself a FAR plugin to solve this problem (and for other toolkits too): http://blog.thecybershadow.net/2010/04/02/envman-far-plugin-to-manage-your-environment/

I don't event recognize what language that is written in. Is that reading and writing to the registry? -- /Jacob Carlborg
Jan 25 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-01-25 17:12, Andrej Mitrovic wrote:
 It's good old Pascal, much hated by C wizards. :D

Well, that explains, a lot :) -- /Jacob Carlborg
Jan 25 2011
prev sibling next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tue, 25 Jan 2011 10:46:45 +0200, Jacob Carlborg <doob me.com> wrote:

  But the problem is the bash scripts, I'm  not sure if a Windows version  
 is possible.

For what it's worth, I'm a FAR Manager user, and I've written myself a FAR plugin to solve this problem (and for other toolkits too): http://blog.thecybershadow.net/2010/04/02/envman-far-plugin-to-manage-your-environment/ -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jan 25 2011
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 25 Jan 2011 03:22:22 -0500, Lars T. Kyllingstad  
<public kyllingen.nospamnet> wrote:

 On Tue, 25 Jan 2011 09:14:06 +0100, Don wrote:

 Nick Sabalausky wrote:
 "Jacob Carlborg" <doob me.com> wrote in message
 news:ihkvrr$1l02$1 digitalmars.com...
 I've created a tool that installs and manages D compilers and
 different versions.

 Description:

 DVM allows you to easily download and install D compilers and manage
 different versions of the compilers. When you switch D compiler with
 the "use" command the compiler will only be available in the current
 shell. This allows you to have one version of the compiler in one
 shell and another version in another shell. For example, have a D1
 version in one shell and a D2 version in another.

 The tool is available at bitbucket: https://bitbucket.org/doob/dvm The
 wiki contains installation and usage instructions:
 https://bitbucket.org/doob/dvm/wiki/Home

 Platforms: currently only Posix

This is the second thing this week that I'd been intending to do and have been thrilled to be beaten to the punch :) You can bet I'll take a crack at porting it to windows...uhhh...assuming I can find the time...heh ;)

then use a trivial batch file. (Uses junction from sysinternals to make a symlink). --- junction c:\dmd c:\olddmd\dmd%1 > nul if not errorlevel 0 echo don't have version %1 --- eg, usedmd 2051

Won't the script have to somehow set the import and library paths as well, so that DMD finds its corresponding druntime/phobos versions?

No, dmd uses the config file in the same directory as the exe. This config file contains those paths. -Steve
Jan 25 2011
prev sibling next sibling parent "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
On Tue, 25 Jan 2011 08:22:40 -0500, Steven Schveighoffer wrote:

 On Tue, 25 Jan 2011 03:22:22 -0500, Lars T. Kyllingstad
 <public kyllingen.nospamnet> wrote:
 
 On Tue, 25 Jan 2011 09:14:06 +0100, Don wrote:

 Nick Sabalausky wrote:
 "Jacob Carlborg" <doob me.com> wrote in message
 news:ihkvrr$1l02$1 digitalmars.com...
 I've created a tool that installs and manages D compilers and
 different versions.

 Description:

 DVM allows you to easily download and install D compilers and manage
 different versions of the compilers. When you switch D compiler with
 the "use" command the compiler will only be available in the current
 shell. This allows you to have one version of the compiler in one
 shell and another version in another shell. For example, have a D1
 version in one shell and a D2 version in another.

 The tool is available at bitbucket: https://bitbucket.org/doob/dvm
 The wiki contains installation and usage instructions:
 https://bitbucket.org/doob/dvm/wiki/Home

 Platforms: currently only Posix

This is the second thing this week that I'd been intending to do and have been thrilled to be beaten to the punch :) You can bet I'll take a crack at porting it to windows...uhhh...assuming I can find the time...heh ;)

and then use a trivial batch file. (Uses junction from sysinternals to make a symlink). --- junction c:\dmd c:\olddmd\dmd%1 > nul if not errorlevel 0 echo don't have version %1 --- eg, usedmd 2051

Won't the script have to somehow set the import and library paths as well, so that DMD finds its corresponding druntime/phobos versions?

No, dmd uses the config file in the same directory as the exe. This config file contains those paths.

Ah, forgot about dmd.conf. I always install DMD in the /usr/local tree and define DFLAGS as an environment variable. Does it look in the executable directory on Linux too? If so, does that take precedence over /etc/dmd.conf and environment variables? -Lars
Jan 25 2011
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 25 Jan 2011 08:32:42 -0500, Lars T. Kyllingstad  
<public kyllingen.nospamnet> wrote:


 Does it look in the executable directory on Linux too?  If so, does that
 take precedence over /etc/dmd.conf and environment variables?

http://www.digitalmars.com/d/2.0/dmd-linux.html#dmd_conf -Steve
Jan 25 2011
prev sibling next sibling parent "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
On Tue, 25 Jan 2011 08:48:25 -0500, Steven Schveighoffer wrote:

 On Tue, 25 Jan 2011 08:32:42 -0500, Lars T. Kyllingstad
 <public kyllingen.nospamnet> wrote:
 
 
 Does it look in the executable directory on Linux too?  If so, does
 that take precedence over /etc/dmd.conf and environment variables?

http://www.digitalmars.com/d/2.0/dmd-linux.html#dmd_conf

Ah, thanks. I'll RTFM next time. ;) -Lars
Jan 25 2011
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Personally I use Console2, and I've a hotkey to open a DMD session (it
just adds DMD to path really).
Jan 25 2011
prev sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
It's good old Pascal, much hated by C wizards. :D
Jan 25 2011
prev sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Jacob Carlborg wrote:
 Platforms: currently only Posix
=20

only posix *with bash shell*. A lot of people use other shells, including non-Bourne shells (most frequent are zsh, ksh and tcsh). Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jan 25 2011
next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2011-01-25 20:33, "Jérôme M. Berger" wrote:
 Jacob Carlborg wrote:
 Platforms: currently only Posix

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? -- /Jacob Carlborg
Jan 25 2011
next sibling parent Lutger Blijdestijn <lutger.blijdestijn gmail.com> writes:
Jacob Carlborg wrote:

 On 2011-01-25 20:33, "Jérôme M. Berger" wrote:
 Jacob Carlborg wrote:
 Platforms: currently only Posix

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?

I know it's possible to hit some pretty common subset that works in most shells, though I don't have any experience. There is a posix specification for shells, bash is supposed to follow that if ran as sh: http://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html There are entire books an the subject, this is a nice small article about the common stuff: http://www.linux.com/archive/feature/34658
Jan 25 2011
prev sibling next sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Jacob Carlborg wrote:
 On 2011-01-25 20:33, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Jacob Carlborg wrote:
 Platforms: currently only Posix

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 an=

 even less about non-bourne shells, will it be possible to port to other=

 shells? How much do they differ?
=20

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 --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jan 25 2011
parent Jacob Carlborg <doob me.com> writes:
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

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?

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
Jan 26 2011
prev sibling parent reply Jesse Phillips <jessekphillips+D gmail.com> writes:
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...
Jan 25 2011
parent reply Jacob Carlborg <doob me.com> writes:
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
Jan 26 2011
next sibling parent reply Daniel Gibson <metalcaedes gmail.com> writes:
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
Jan 26 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-01-26 19:12, Daniel Gibson wrote:
 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.

That sounds like something I could use.
 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.

On Mac OS X I use .bash_profile, I don't know if .profile and/or .bashrc works. The bash man page (http://linux.die.net/man/1/bash) says: "When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable." And: "When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists." I'm not sure I know the difference between "an interactive login shell" and one that isn't. I'm not 100% sure in what file to put the script in. But what I want is to run a script when a new shell is started, like when you open the Terminal in Ubuntu/Mac OS X or opens a new tab in the terminal.
 Cheers,
 - Daniel

-- /Jacob Carlborg
Jan 26 2011
prev sibling next sibling parent Jesse Phillips <jessekphillips+D gmail.com> writes:
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.
Jan 26 2011
prev sibling next sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

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 =



 even less about non-bourne shells, will it be possible to port to oth=



 shells? How much do they differ?

 --=20
 /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. =20

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! --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jan 26 2011
parent reply Jacob Carlborg <doob me.com> writes:
On 2011-01-26 21:04, "Jérôme M. Berger" wrote:
 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.

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;

Is it possible to detect what shell is running and then load the correct version?
 - 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.

The contents of $dvm_result_path will only export one variable.
 		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!

OK, how else can I do the same thing? BTW this is how RVM (Ruby Version Manager) works, where I got the idea from. The whole RVM is written in shell script and it's sourced in .bashrc. -- /Jacob Carlborg
Jan 26 2011
parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Jacob Carlborg wrote:
 On 2011-01-26 21:04, "J=C3=A9r=C3=B4me M. Berger" wrote:
     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;

Is it possible to detect what shell is running and then load the correc=

 version?
=20

source the correct version from the startup file. On installation, the SHELL environment variable should tell you which shell is used.
 - 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.

The contents of $dvm_result_path will only export one variable. =20

path (I do not know since I am not a bash user)? If not, why do you need to call it in __dvm_setup_environment?
         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!

OK, how else can I do the same thing? BTW this is how RVM (Ruby Version=

 Manager) works, where I got the idea from. The whole RVM is written in
 shell script and it's sourced in .bashrc.
=20

-z "$dvm_prefix" ]] ; then ..." So the file will look like: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D8<------------------------------ if [[ -z "$dvm_prefix" ]] ; then if [[ -n "$HOME" ]] ; then dvm_prefix=3D"$HOME/." else echo "No \$dvm_prefix was provided and " echo "$(id | \sed -e's/^[^(]*(//' -e 's/).*//') has no \$HOME defined." fi fi if [[ ! -z "$dvm_prefix" ]] ; then ... fi ------------------------------>8=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jan 27 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-01-27 23:34, "Jérôme M. Berger" wrote:
 Jacob Carlborg wrote:
 On 2011-01-26 21:04, "Jérôme M. Berger" wrote:
      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;

Is it possible to detect what shell is running and then load the correct version?

source the correct version from the startup file. On installation, the SHELL environment variable should tell you which shell is used.

Ah, right. Didn't think of that.
 - 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.

The contents of $dvm_result_path will only export one variable.

path (I do not know since I am not a bash user)? If not, why do you need to call it in __dvm_setup_environment?

I don't know actually. I'll have to test that.
          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!

OK, how else can I do the same thing? BTW this is how RVM (Ruby Version Manager) works, where I got the idea from. The whole RVM is written in shell script and it's sourced in .bashrc.

-z "$dvm_prefix" ]] ; then ..." So the file will look like: ==============================8<------------------------------ if [[ -z "$dvm_prefix" ]] ; then if [[ -n "$HOME" ]] ; then dvm_prefix="$HOME/." else echo "No \$dvm_prefix was provided and " echo "$(id | \sed -e's/^[^(]*(//' -e 's/).*//') has no \$HOME defined." fi fi if [[ ! -z "$dvm_prefix" ]] ; then ... fi ------------------------------>8============================== Jerome

Yeah, I kind of notice that. The "exit" didn't work out that well. -- /Jacob Carlborg
Jan 28 2011
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2011-01-26 14:58, Steven Schveighoffer wrote:
 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.

/bin/sh is not a symlink on Mac OS X. I guess I just can try to use sh instead of bash.
 I typically find /bin/sh features to be enough for implementing most
 scripts.

I have no idea. I need to be able use the following commands/functions: export, source, builtin hash, rm, echo, exit, exec
 A good reference (if you don't have it) is Unix in a nutshell, probably
 my most used textbook.

Ok, I'll have a look.
 -Steve

-- /Jacob Carlborg
Jan 26 2011
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Jacob Carlborg" <doob me.com> wrote in message 
news:ihq02n$28ki$1 digitalmars.com...
 On 2011-01-26 14:58, Steven Schveighoffer wrote:
 On Wed, 26 Jan 2011 03:36:24 -0500, Jacob Carlborg <doob me.com> wrote:

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

I have no idea. I need to be able use the following commands/functions: export, source, builtin hash, rm, echo, exit, exec

Can't all (or most) of that be done in straight D?
Jan 26 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-01-26 21:53, Nick Sabalausky wrote:
 "Jacob Carlborg"<doob me.com>  wrote in message
 news:ihq02n$28ki$1 digitalmars.com...
 On 2011-01-26 14:58, Steven Schveighoffer wrote:
 On Wed, 26 Jan 2011 03:36:24 -0500, Jacob Carlborg<doob me.com>  wrote:

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

I have no idea. I need to be able use the following commands/functions: export, source, builtin hash, rm, echo, exit, exec

Can't all (or most) of that be done in straight D?

It all comes done to one thing, the "source" function. If you launch an application in a shell that application can't set environment variables that will be available to the shell when the application exits. So instead I have most of the application written in D with a bash function that wraps the application. It works like this: 1. The function calls the D application 2. The D application performs all it needs to and writes a shell script to a file 3. The bash function calls "source" with this file as a parameter -- /Jacob Carlborg
Jan 26 2011
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2011-01-26 21:47, Steven Schveighoffer wrote:
 On Wed, 26 Jan 2011 15:24:56 -0500, Jacob Carlborg <doob me.com> wrote:

 On 2011-01-26 14:58, Steven Schveighoffer wrote:
 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.

/bin/sh is not a symlink on Mac OS X. I guess I just can try to use sh instead of bash.

Yes, it should limit you to /bin/sh supported commands
 I typically find /bin/sh features to be enough for implementing most
 scripts.

I have no idea. I need to be able use the following commands/functions: export, source, builtin hash, rm, echo, exit, exec

export => supported, but has a more limited syntax than bash source => supported via . builtin hash => supported rm => command (shell independent) exit => supported exec => supported -Steve

Ok, thanks. -- /Jacob Carlborg
Jan 26 2011
prev sibling parent reply Michel Fortin <michel.fortin michelf.com> writes:
On 2011-01-26 15:24:56 -0500, Jacob Carlborg <doob me.com> said:

 /bin/sh is not a symlink on Mac OS X. I guess I just can try to use sh 
 instead of bash.

But should it output this? $ /bin/sh --version GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) Copyright (C) 2007 Free Software Foundation, Inc. $ This is on Mac OS X 10.6.6. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Jan 26 2011
parent reply Jacob Carlborg <doob me.com> writes:
On 2011-01-26 23:46, Michel Fortin wrote:
 On 2011-01-26 15:24:56 -0500, Jacob Carlborg <doob me.com> said:

 /bin/sh is not a symlink on Mac OS X. I guess I just can try to use sh
 instead of bash.

But should it output this? $ /bin/sh --version GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) Copyright (C) 2007 Free Software Foundation, Inc. $ This is on Mac OS X 10.6.6.

I have no idea. Perhaps it will run bash in a mode which is compatible with sh. -- /Jacob Carlborg
Jan 27 2011
parent Daniel Gibson <metalcaedes gmail.com> writes:
Am 27.01.2011 13:05, schrieb Jacob Carlborg:
 On 2011-01-26 23:46, Michel Fortin wrote:
 On 2011-01-26 15:24:56 -0500, Jacob Carlborg <doob me.com> said:

 /bin/sh is not a symlink on Mac OS X. I guess I just can try to use sh
 instead of bash.

But should it output this? $ /bin/sh --version GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) Copyright (C) 2007 Free Software Foundation, Inc. $ This is on Mac OS X 10.6.6.

I have no idea. Perhaps it will run bash in a mode which is compatible with sh.

Or just in normal mode, like linux distributions have been done for ages (and some still do). bash *is* compatible with sh (=> everything that runs in sh runs in bash), but sh is not compatible with bash (=> bash has features that other sh-compliant shells don't have and that are not required by the corresponding POSIX standard).
Jan 27 2011
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
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
Jan 26 2011
prev sibling next sibling parent Russel Winder <russel russel.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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 =20
 scripts.

And the only guaranteed portable script -- assuming Windows without Cygwin or MSYS is excluded ! [ . . . ] --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 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
Jan 26 2011
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
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
Jan 26 2011
prev sibling next sibling parent Brad <brad.lanam.comp_nospam nospam_gmail.com> writes:
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.
Jan 26 2011
prev sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Wed, 26 Jan 2011 15:24:56 -0500, Jacob Carlborg <doob me.com> wrote:

 On 2011-01-26 14:58, Steven Schveighoffer wrote:
 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.

/bin/sh is not a symlink on Mac OS X. I guess I just can try to use sh instead of bash.

Yes, it should limit you to /bin/sh supported commands
 I typically find /bin/sh features to be enough for implementing most
 scripts.

I have no idea. I need to be able use the following commands/functions: export, source, builtin hash, rm, echo, exit, exec

export => supported, but has a more limited syntax than bash source => supported via . builtin hash => supported rm => command (shell independent) exit => supported exec => supported -Steve
Jan 26 2011