* [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts?
@ 2007-04-01 6:02 Peter Volkov
2007-04-01 6:57 ` Christopher Sawtell
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Peter Volkov @ 2007-04-01 6:02 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 558 bytes --]
Hello.
Path of some utilities in coreutils-6.7-r1 changed from /usr/bin to /bin
and vice versa. This cause some scripts became broken as they relied on
the full path to executable. The question is: does there exist best
practice on how to avoid this problem in future? Should we set some
default PATH in scripts or should we call "command -p program"? Or as
this is mainly problem for scripts that work in cron we should suggest
users to set PATH in crontab? Or may be we should fix coreutils to
create all possible symlinks?
TIA,
--
Peter.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts?
2007-04-01 6:02 [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts? Peter Volkov
@ 2007-04-01 6:57 ` Christopher Sawtell
2007-04-01 6:57 ` Guillermo A. Amaral
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Christopher Sawtell @ 2007-04-01 6:57 UTC (permalink / raw
To: gentoo-dev
On Sunday 01 April 2007, Peter Volkov wrote:
> Hello.
>
> Path of some utilities in coreutils-6.7-r1 changed from /usr/bin to /bin
> and vice versa. This cause some scripts became broken as they relied on
> the full path to executable. The question is: does there exist best
> practice on how to avoid this problem in future?
Traditionally, all programs needed to boot the machine into single-user mode,
together with an editor, were placed in /bin or /sbin. This allowed an
administrator to do simple tasks such as simple editing of files in /etc,
checking and repairing filesystems, etc.. without having any other partitions
being mounted.
Now-a-days it's probably all a bit moot because we have have bootable CDs and
not as important as it used to be, but I am profoundly irritated when I find
that when I boot to single user mode on Gentoo/Linux that I have to unmount
my non-/ partitions to file check them, and then - even more irritating -
have to remember to remount them in order to get a clean reboot, even worse
is that vi is unavailable when you are repair mode because it is in /usr/bin.
Thus one has to make do with ed. :-(
> Should we set some
> default PATH in scripts or should we call "command -p program"? Or as
> this is mainly problem for scripts that work in cron we should suggest
> users to set PATH in crontab? Or may be we should fix coreutils to
> create all possible symlinks?
--
CS
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts?
2007-04-01 6:02 [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts? Peter Volkov
2007-04-01 6:57 ` Christopher Sawtell
@ 2007-04-01 6:57 ` Guillermo A. Amaral
2007-04-01 7:01 ` [gentoo-dev] /{"", usr/}bin " Alec Warner
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Guillermo A. Amaral @ 2007-04-01 6:57 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 977 bytes --]
On Sunday 01 April 2007, Peter Volkov wrote:
> Hello.
>
> Path of some utilities in coreutils-6.7-r1 changed from /usr/bin to /bin
> and vice versa. This cause some scripts became broken as they relied on
> the full path to executable. The question is: does there exist best
> practice on how to avoid this problem in future? Should we set some
> default PATH in scripts or should we call "command -p program"? Or as
> this is mainly problem for scripts that work in cron we should suggest
> users to set PATH in crontab? Or may be we should fix coreutils to
> create all possible symlinks?
>
> TIA,
IMHO I have always like the PATH in script approach, it seems like a
reasonable solution to me.
--
Guillermo A. Amaral, CSE
# Free & Open Source Advocate
& nick: guillermoamaral
@ blog: http://blog.guillermoamaral.com/
@ site: http://www.guillermoamaral.com/
$ irc: guillermoamaral@freenode
% gpg: http://downloads.guillermoamaral.com/public.asc
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] /{"", usr/}bin path changed. What is the right solution for scripts?
2007-04-01 6:02 [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts? Peter Volkov
2007-04-01 6:57 ` Christopher Sawtell
2007-04-01 6:57 ` Guillermo A. Amaral
@ 2007-04-01 7:01 ` Alec Warner
2007-04-01 7:09 ` Mike Frysinger
2007-04-01 9:56 ` [gentoo-dev] /{"",usr/}bin " Roy Marples
2007-04-01 15:15 ` Peter Volkov
4 siblings, 1 reply; 10+ messages in thread
From: Alec Warner @ 2007-04-01 7:01 UTC (permalink / raw
To: gentoo-dev
> Hello.
>
> Path of some utilities in coreutils-6.7-r1 changed from /usr/bin to /bin
> and vice versa. This cause some scripts became broken as they relied on
> the full path to executable. The question is: does there exist best
> practice on how to avoid this problem in future? Should we set some
> default PATH in scripts or should we call "command -p program"? Or as
> this is mainly problem for scripts that work in cron we should suggest
> users to set PATH in crontab? Or may be we should fix coreutils to
> create all possible symlinks?
>
> TIA,
> --
> Peter.
>
One idea that comes to mind is /usr/bin/env $bin
For cron, one would need to set the PATH to something sane though.
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] /{"", usr/}bin path changed. What is the right solution for scripts?
2007-04-01 7:01 ` [gentoo-dev] /{"", usr/}bin " Alec Warner
@ 2007-04-01 7:09 ` Mike Frysinger
0 siblings, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2007-04-01 7:09 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 211 bytes --]
On Sunday 01 April 2007, Alec Warner wrote:
> For cron, one would need to set the PATH to something sane though.
i thought sane cron systems would setup a sane PATH for you:
/sbin:/usr/sbin:/bin:/usr/bin
-mike
[-- Attachment #2: Type: application/pgp-signature, Size: 827 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts?
2007-04-01 6:02 [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts? Peter Volkov
` (2 preceding siblings ...)
2007-04-01 7:01 ` [gentoo-dev] /{"", usr/}bin " Alec Warner
@ 2007-04-01 9:56 ` Roy Marples
2007-04-01 15:15 ` Peter Volkov
4 siblings, 0 replies; 10+ messages in thread
From: Roy Marples @ 2007-04-01 9:56 UTC (permalink / raw
To: gentoo-dev
On Sun, 01 Apr 2007 10:02:27 +0400
Peter Volkov <pva@gentoo.org> wrote:
> The question is: does there
> exist best practice on how to avoid this problem in future? Should we
> set some default PATH in scripts or should we call "command -p
> program"?
A lot of Gentoo scriptlets such as gcc-config and others
source /etc/init.d/function.sh which sets up a default $PATH for you if
needed.
Thanks
Roy
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts?
2007-04-01 6:02 [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts? Peter Volkov
` (3 preceding siblings ...)
2007-04-01 9:56 ` [gentoo-dev] /{"",usr/}bin " Roy Marples
@ 2007-04-01 15:15 ` Peter Volkov
2007-04-01 15:21 ` Ciaran McCreesh
4 siblings, 1 reply; 10+ messages in thread
From: Peter Volkov @ 2007-04-01 15:15 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]
On Sun, 2007-04-01 at 00:01 -0700, Alec Warner wrote:
> One idea that comes to mind is /usr/bin/env $bin
And here we return to the problem that one day /usr/bin/env, could
become /bin/env... Or that /usr/ sometimes is not mounted during boot.
Thus, well. Seems that have sane PATH in the beginning of script is the
best solution.
On Sun, 2007-04-01 at 03:09 -0400, Mike Frysinger wrote:
> On Sunday 01 April 2007, Alec Warner wrote:
> > For cron, one would need to set the PATH to something sane though.
>
> i thought sane cron systems would setup a sane PATH for you:
> /sbin:/usr/sbin:/bin:/usr/bin
At least fcron does not have default PATH compiled in. It inherits PATH
from environment. When we start fcron from init.d system it has some
default path set from /etc/init.d/function.sh (as Roy pointed).
Well. Thank you all for your answers. At least now I know that I have
not overlooked something trivial and seems that the best solution is to
set
PATH={PATH}:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
in the beginning of all shell scripts and to avoid usage of full path to
executable.
--
Peter.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts?
2007-04-01 15:15 ` Peter Volkov
@ 2007-04-01 15:21 ` Ciaran McCreesh
2007-04-01 15:46 ` [gentoo-dev] /{"", usr/}bin " Alec Warner
0 siblings, 1 reply; 10+ messages in thread
From: Ciaran McCreesh @ 2007-04-01 15:21 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 493 bytes --]
On Sun, 01 Apr 2007 19:15:13 +0400
Peter Volkov <pva@gentoo.org> wrote:
> On Sun, 2007-04-01 at 00:01 -0700, Alec Warner wrote:
> > One idea that comes to mind is /usr/bin/env $bin
>
> And here we return to the problem that one day /usr/bin/env, could
> become /bin/env... Or that /usr/ sometimes is not mounted during boot.
env not being in /usr/bin will break an awful lot of stuff. It's listed
in many textbooks as being the safe way of doing things.
--
Ciaran McCreesh
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] /{"", usr/}bin path changed. What is the right solution for scripts?
2007-04-01 15:21 ` Ciaran McCreesh
@ 2007-04-01 15:46 ` Alec Warner
2007-04-02 10:42 ` Peter Volkov
0 siblings, 1 reply; 10+ messages in thread
From: Alec Warner @ 2007-04-01 15:46 UTC (permalink / raw
To: gentoo-dev
> On Sun, 01 Apr 2007 19:15:13 +0400
> Peter Volkov <pva@gentoo.org> wrote:
>> On Sun, 2007-04-01 at 00:01 -0700, Alec Warner wrote:
>> > One idea that comes to mind is /usr/bin/env $bin
>>
>> And here we return to the problem that one day /usr/bin/env, could
>> become /bin/env... Or that /usr/ sometimes is not mounted during boot.
On Gentoo, env is in /bin and /usr/bin
/usr/bin/env is present on every unix system I've ever been on (I kind of
make it a habit to check) and probably a ton I've never used ;)
However using env really only makes sense in the
#!/usr/bin/env foo
case. Pretty much every other case you should be setting PATH to
something proper in your script.
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] /{"", usr/}bin path changed. What is the right solution for scripts?
2007-04-01 15:46 ` [gentoo-dev] /{"", usr/}bin " Alec Warner
@ 2007-04-02 10:42 ` Peter Volkov
0 siblings, 0 replies; 10+ messages in thread
From: Peter Volkov @ 2007-04-02 10:42 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 867 bytes --]
On Sun, 2007-04-01 at 16:21 +0100, Ciaran McCreesh wrote:
> env not being in /usr/bin will break an awful lot of stuff. It's listed
> in many textbooks as being the safe way of doing things.
On Sun, 2007-04-01 at 08:46 -0700, Alec Warner wrote:
> However using env really only makes sense in the
>
> #!/usr/bin/env foo
>
> case. Pretty much every other case you should be setting PATH to
> something proper in your script.
Thank you for remarks.
BTW. Looking into sources I found that env itself does not have default
PATH but calls execvp () which have VERY reduced PATH=":/bin:/usr/bin" .
command -p by default in bash uses the following
PATH /bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc
So I think as there is no standard on what is the default PATH the most
viable solution is to set default PATH in the script itself.
--
Peter.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-04-02 10:47 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-01 6:02 [gentoo-dev] /{"",usr/}bin path changed. What is the right solution for scripts? Peter Volkov
2007-04-01 6:57 ` Christopher Sawtell
2007-04-01 6:57 ` Guillermo A. Amaral
2007-04-01 7:01 ` [gentoo-dev] /{"", usr/}bin " Alec Warner
2007-04-01 7:09 ` Mike Frysinger
2007-04-01 9:56 ` [gentoo-dev] /{"",usr/}bin " Roy Marples
2007-04-01 15:15 ` Peter Volkov
2007-04-01 15:21 ` Ciaran McCreesh
2007-04-01 15:46 ` [gentoo-dev] /{"", usr/}bin " Alec Warner
2007-04-02 10:42 ` Peter Volkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox