while man env
on linux seems indicate can set new environment variables before executing command. unfortunately, when set new variables in file's shebang on linux systems, file never executes.
#!/usr/bin/env var1=foo bash echo $var1
when execute file on centos or ubuntu machine, sits there.
$ ./shell-env.sh <nothing happens>
what find particularly bizarre works fine on os x bsd env
.
$ ./shell-env.sh foo $
is difference between bsd env
, linux env
? why man pages linux seem should work same way on bsd?
p.s. use case here override path
variable, can try find ruby
on system that's not on path
.
thank in advance!
there's way manipulate environment before executing ruby script, without using wrapper script of kind, it's not pretty:
#!/bin/bash export foo=bar exec ruby -x "$0" "$@" #!ruby puts env['foo']
this reserved esoteric situations need manipulate e.g. path
or ld_library_path
before executing program, , needs self-contained reason. works perl , possibly others too!
Comments
Post a Comment