in reply to Re^3: [OT] 'perl' is not the 'perl' reported by 'which perl' (which vs type References)
in thread [OT] 'perl' is not the 'perl' reported by 'which perl'
"... most people use the which command and have never even heard of the type command! ..."
That's very interesting. I've used quite an array of shells since the '80s (sh, ksh, bash, csh, tcsh, and others). I'm reasonably certain I've used which almost exclusively. I couldn't definitely say I've never heard of type but, had I been asked about it yesterday, I would have had to look it up. I decided to look into this a bit further.
There appears to be some redundant information (<some-command> is) with type; however, in isolation that doesn't appear to be a problem.
$ which perl /.../perl $ type perl perl is /.../perl
I did encounter an issue in this scenario:
$ ls -l `which perl` -rwxr-xr-x 2 ken None 169225 Jun 23 20:35 /.../perl $ ls -l `type perl` ls: cannot access 'perl': No such file or directory ls: cannot access 'is': No such file or directory -rwxr-xr-x 2 ken None 169225 Jun 23 20:35 /.../perl
On the other hand, it's particularly useful here:
$ which perle which: no perle in (...) $ type perle perle is aliased to `perl -Mstrict -Mwarnings -Mautodie=:all -MCarp::A +lways -E'
So, it looks like both commands have their uses in different situations. I will remember type from now on and use it where needed. Thanks for pointing out this command. [Edit: Actually, it looks like LanX was the first to mention type, so thanks Rolf.]
[In case anyone was wondering, the /.../perl represents identical pathnames throughout. With "perlbrew", those paths are long and would probably wrap.]
— Ken
|
---|