PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > invoking the non-builtin command (bash)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

invoking the non-builtin command (bash)

Réponse
 
LinkBack Outils de la discussion
Vieux 08/11/2006, 11h29   #1
Yakov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut invoking the non-builtin command (bash)

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

  Réponse avec citation
Vieux 08/11/2006, 11h41   #2
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: invoking the non-builtin command (bash)

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
  Réponse avec citation
Vieux 08/11/2006, 12h01   #3
Yakov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: invoking the non-builtin command (bash)

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

  Réponse avec citation
Vieux 08/11/2006, 12h25   #4
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: invoking the non-builtin command (bash)

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
  Réponse avec citation
Vieux 08/11/2006, 13h38   #5
Yakov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: invoking the non-builtin command (bash)

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

  Réponse avec citation
Vieux 08/11/2006, 13h50   #6
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: invoking the non-builtin command (bash)

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
  Réponse avec citation
Vieux 08/11/2006, 18h04   #7
Michael Tosch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: invoking the non-builtin command (bash)

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
  Réponse avec citation
Vieux 08/11/2006, 18h42   #8
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: invoking the non-builtin command (bash)

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 09h29.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15299 seconds with 16 queries