Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-06 Thread Matthew Woehlke

Mike Coleman wrote:

It would be nice if there was some really brief syntax for

$(type -p somecommand)


p() {
  local what=$(type -p $1)
  shift 1
  $@ $what
}

p foobar ls -l
p foobar strings
...etc

also, 'complete -c p'

--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
--
Anyone who is capable of getting themselves made President should on no 
account be allowed to do the job. -- The Hitchhiker's Guide to the 
Galaxy (Douglas Adams)






feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Mike Coleman
It would be nice if there was some really brief syntax for

$(type -p somecommand)




Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Mike Coleman
[Oops--I sent that incomplete.]

It would be nice if there was some really brief syntax for

$(type -p somecommand)

I find myself using this all day long with 'ls', 'file', 'ldd',
'strings', 'nm', etc., and the current incantation is just long enough
to be annoying.

Mike




Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Chris F.A. Johnson

On Thu, 2 Apr 2009, Mike Coleman wrote:


[Oops--I sent that incomplete.]

It would be nice if there was some really brief syntax for

   $(type -p somecommand)

I find myself using this all day long with 'ls', 'file', 'ldd',
'strings', 'nm', etc., and the current incantation is just long enough
to be annoying.


   Use a function, e.g.:

p()
{
  pp=$( type -p $@ )
}


--
   Chris F.A. Johnson, webmaster http://woodbine-gerrard.com
   = Do not reply to the From: address; use Reply-To: 
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)




Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Mike Coleman
On Thu, Apr 2, 2009 at 11:33 AM, Chris F.A. Johnson c...@freeshell.org wrote:
 On Thu, 2 Apr 2009, Mike Coleman wrote:

 [Oops--I sent that incomplete.]

 It would be nice if there was some really brief syntax for

   $(type -p somecommand)

 I find myself using this all day long with 'ls', 'file', 'ldd',
 'strings', 'nm', etc., and the current incantation is just long enough
 to be annoying.

   Use a function, e.g.:

 p()
 {
  pp=$( type -p $@ )
 }


Hmm.  So I would use this like so?

$ p somecommand; ls -l $pp

I guess it's not obvious that that's an improvement.  Along these
lines, though, is there some way to do something like this

script named 'p':
$!/bin/bash
exec type -p $1

which could then be used like

$ ls -l $(p somecommand)

except without the external script?




Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Chris F.A. Johnson

On Thu, 2 Apr 2009, Mike Coleman wrote:


On Thu, Apr 2, 2009 at 11:33 AM, Chris F.A. Johnson c...@freeshell.org wrote:

On Thu, 2 Apr 2009, Mike Coleman wrote:


[Oops--I sent that incomplete.]

It would be nice if there was some really brief syntax for

  $(type -p somecommand)

I find myself using this all day long with 'ls', 'file', 'ldd',
'strings', 'nm', etc., and the current incantation is just long enough
to be annoying.


  Use a function, e.g.:

p()
{
 pp=$( type -p $@ )
}



Hmm.  So I would use this like so?

   $ p somecommand; ls -l $pp


   If that's what you want, you can include it in the function:

p()
{
  _p=$( type -p $@ )
  [ -n $_p ]  ls -l $_p
}

--
   Chris F.A. Johnson, webmaster http://woodbine-gerrard.com
   ===
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)




Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Jan Schampera
Mike Coleman wrote:
 [Oops--I sent that incomplete.]
 
 It would be nice if there was some really brief syntax for
 
 $(type -p somecommand)
 
 I find myself using this all day long with 'ls', 'file', 'ldd',
 'strings', 'nm', etc., and the current incantation is just long enough
 to be annoying.
 
 Mike
 
 

Why do you need to get the path of a program that's in PATH?

If you only need to check if it's in PATH then you can use other things,
and these in a loop.

J.





Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Stephane CHAZELAS
2009-04-2, 12:33(-04), Chris F.A. Johnson:
 On Thu, 2 Apr 2009, Mike Coleman wrote:

 [Oops--I sent that incomplete.]

 It would be nice if there was some really brief syntax for

$(type -p somecommand)

 I find myself using this all day long with 'ls', 'file', 'ldd',
 'strings', 'nm', etc., and the current incantation is just long enough
 to be annoying.

 Use a function, e.g.:

 p()
 {
pp=$( type -p $@ )
 }
[...]

For information, zsh has =cmd, which is a globbing operator.

$ sum =bash
59911   709

-- 
Stéphane


Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Mike Coleman
On Thu, Apr 2, 2009 at 3:16 PM, Jan Schampera jan.schamp...@web.de wrote:
 Mike Coleman wrote:
 [Oops--I sent that incomplete.]

 It would be nice if there was some really brief syntax for

     $(type -p somecommand)

 I find myself using this all day long with 'ls', 'file', 'ldd',
 'strings', 'nm', etc., and the current incantation is just long enough
 to be annoying.

 Mike



 Why do you need to get the path of a program that's in PATH?

Well, for example, I may have an undocumented program 'foobar' in my
path, and running 'strings' on it is a good way to grab its usage
message and/or look at its embedded messages, etc.  I might run 'ldd'
on it to see what libs it's depending on, 'ls' to see when it was last
updated, who owns it, etc., 'file' to see what it is (script or
executable, 32-bit or 64, etc.).

Obviously for all of these, I could do a 'type -p' first and then
paste the result in as the argument for these other commands, but it's
handy not to have to do that.  Currently I have a whole bunch of
aliases (pls, pfile, pldd, pstrings, etc.) to do this, but it seems
like a useful enough pattern that it'd be worth having a general
shortcut for it.

Mike




Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Mike Coleman
On Thu, Apr 2, 2009 at 11:57 AM, Chris F.A. Johnson c...@freeshell.org wrote:
   If that's what you want, you can include it in the function:

 p()
 {
  _p=$( type -p $@ )
  [ -n $_p ]  ls -l $_p
 }

This is more or less what I'm doing now, with one function for each
command.  I suppose the command could be an argument, too, so that one
could run

$ p ls somecommand
$ p ldd somecommand
$ p strings somecommand
$ p file somecommand
$ p nm somecommand

though there's no command completion this way.  I guess I could add that, too.

One problem, though, like the wait for slot feature I suggested a
few months ago, is that something like this is quite a bit more useful
when it's available everywhere (without having to drag one's bash
library around).

Mike




Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Bernd Eggink

Mike Coleman schrieb:

On Thu, Apr 2, 2009 at 11:57 AM, Chris F.A. Johnson c...@freeshell.org wrote:

  If that's what you want, you can include it in the function:

p()
{
 _p=$( type -p $@ )
 [ -n $_p ]  ls -l $_p
}


This is more or less what I'm doing now, with one function for each
command.  I suppose the command could be an argument, too, so that one
could run

$ p ls somecommand
$ p ldd somecommand
$ p strings somecommand
$ p file somecommand
$ p nm somecommand

though there's no command completion this way.  I guess I could add that, too.

One problem, though, like the wait for slot feature I suggested a
few months ago, is that something like this is quite a bit more useful
when it's available everywhere (without having to drag one's bash
library around).


I have a more universal function (also named p) here:

http://www.sudrala.de/en_d/shell-cmdexp.html

Maybe it is of use for you, too.

Regards,
Bernd


--
Bernd Eggink
http://sudrala.de