|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Some commands exists both in /usr/bin and as bash builtin ('time'
command is one of such commands). I want to invoke the non-builtin version of command X, what is short way of doing it ? (In case of 'time', I can do /usr/bin/time which is good enough, but what if non-builtin command X is in PATH but not necessarily in /usr/bin ?) Thanks Yakov |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
2006-11-8, 03:29(-08), Yakov:
> Some commands exists both in /usr/bin and as bash builtin ('time' > command is one of such commands). > > I want to invoke the non-builtin version of command X, what is > short way of doing it ? [...] command X note that "time" is a keyword in bash, not a command, so that you can do time foo | bar to time both foo and bar at the same time. You would need command time foo | command time bar and you need to do the arithmetics yourself. zsh time gives more useful information than bash's BTW. -- Stéphane |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Stephane CHAZELAS wrote:
> 2006-11-8, 03:29(-08), Yakov: > > Some commands exists both in /usr/bin and as bash builtin ('time' > > command is one of such commands). > > > > I want to invoke the non-builtin version of command X, what is > > short way of doing it ? > [...] > > command X > > note that "time" is a keyword in bash, not a command Thanks, 'command time' does it -- invokes /usr/bin/time; But it's confusing because man bash says 'command ... ... Only builtin commands or commands found in the PATH are executed.' (but I want only commands found in PATH and not builtins) but 'command time' invokes /usr/bin/time because 'time' is not shell builtin but a'shell keyword'. Wow. Theoretically, I still wonder of there is variant of 'command' that invokes commands found in the PATH but not builtins. > zsh time gives more useful information than bash's BTW. That's exactly why I want to use /usr/bin/time which has configurable output. (gnu time) Yakov |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
2006-11-8, 04:01(-08), Yakov:
[...] >> note that "time" is a keyword in bash, not a command > > Thanks, 'command time' does it -- invokes /usr/bin/time; > But it's confusing because man bash says 'command ... > ... Only builtin commands or commands found in the PATH > are > executed.' > (but I want only commands found in PATH and not builtins) but > 'command time' invokes /usr/bin/time because 'time' > is not shell builtin but a'shell keyword'. Wow. > > Theoretically, I still wonder of there is variant of 'command' that > invokes commands found in the PATH but not builtins. Indeed, I was confusing with zsh that behaves like that when not in sh/ksh emulation mode. Anyway, with zsh, I'd use =cmd, (=cmd is a globbing operator that expands a command to its full path). With bash, you could do: "$(command -v cmd)" > >> zsh time gives more useful information than bash's BTW. > > That's exactly why I want to use /usr/bin/time which has > configurable output. (gnu time) [...] Note that zsh time output is also configurable. Is there any specific reason why you'd use bash rather than zsh? -- Stéphane |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Stephane CHAZELAS wrote:
> "$(command -v cmd)" "$(command -v cmd)" prints just 'time', not /usr/bin/time as I'd expect. But 'command cmd' invokes /usr/bin/time. Bug ? > Is there any specific reason why you'd use bash rather than zsh? - I find bash bug-free which I find nice (compared to the shell I used before bash); - available on any linux; some of my low-end linuxes don't have zsh; ..... but this is remediable .. because thos are *my* low-end linuxes :-) - I generally use very little non-posi extensions of bash, very little. But I heard good opinions about zsh before. I guess I'd need several, not one, specific reasons in order to think about switching from bash to zsh. What would be, to your mind, 5-10 top resons to switch from bash to zsh ? Yakov |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
2006-11-8, 05:38(-08), Yakov:
> Stephane CHAZELAS wrote: >> "$(command -v cmd)" > > "$(command -v cmd)" prints just 'time', not /usr/bin/time as I'd > expect. type -ap time | awk '/\//{print; exit}' maybe then. > But 'command cmd' invokes /usr/bin/time. Bug ? Could be a bug, depending on how you read the specs. >> Is there any specific reason why you'd use bash rather than zsh? [...] > What would be, to your mind, 5-10 top resons to switch from bash to zsh [...] completion, globbing, short forms, spelling correction, history interactive handling, more consistent syntax, better documentation... -- Stéphane |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Stephane CHAZELAS wrote:
> 2006-11-8, 04:01(-08), Yakov: > [...] >>> note that "time" is a keyword in bash, not a command >> Thanks, 'command time' does it -- invokes /usr/bin/time; >> But it's confusing because man bash says 'command ... >> ... Only builtin commands or commands found in the PATH >> are >> executed.' >> (but I want only commands found in PATH and not builtins) but >> 'command time' invokes /usr/bin/time because 'time' >> is not shell builtin but a'shell keyword'. Wow. >> >> Theoretically, I still wonder of there is variant of 'command' that >> invokes commands found in the PATH but not builtins. > > Indeed, I was confusing with zsh that behaves like that when not > in sh/ksh emulation mode. > > Anyway, with zsh, I'd use =cmd, (=cmd is a globbing operator > that expands a command to its full path). > > With bash, you could do: > > "$(command -v cmd)" > \time seems to work as well(?) -- Michael Tosch @ hp : com |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
2006-11-08, 19:04(+01), Michael Tosch:
[...] >> With bash, you could do: >> >> "$(command -v cmd)" >> > > \time > > seems to work as well(?) Indeed, for a keyword such as time as then it stops from being recognised as such. \echo wouldn't work the same though (the builtin echo would still be picked up). "$(command -v echo)" wouldn't either. Options with zsh: command echo =echo $commands[echo] -- Stéphane |
|
![]() |
| Outils de la discussion | |
|
|