Free Downloads, Community Forum,
FAQs and Developer Resources


Make /Tools Your Home | Link to us

Today's posts | Posts since last visit | Most Active Topics

All Forums Register Login Search Subscriptions My Profile Inbox
Tool Warehouse FAQs Resources Help Member List Address Book Logout

Strange subshel/path failures

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [SFU / Interix / SUA Technology] >> Tools Discussion Forum >> Strange subshel/path failures Page: [1]
Login
Message << Older Topic   Newer Topic >>
Strange subshel/path failures - May 25, '06, 8:29:39 PM   
dotequals

 

Posts: 4
Joined: May 10, '06,
Status: offline
Let's say I want to know what kind of file my cat executable is. I can run file on it, but first I need to know where it is, so I run which on it:

$ which cat
C:\usr\bin\WSFU\bin\cat


Which is fine, except it's a Windows path, and I want to pass it to file, which takes a unix path; so I run winpath2unix on it:

$ winpath2unix $(which cat)
/dev/fs/C/usr/bin/WSFU/bin/cat


Also still fine. But now I try to pass that to file:

$ file $(winpath2unix $(which cat))
' (No such file or directory).n/WSFU/bin/cat


Not fine! Actually, that's really weird. But if I just echo that same subshell command:

$ echo $(winpath2unix $(which cat))
/dev/fs/C/usr/bin/WSFU/bin/cat


it works perfectly. Furthermore, if I pass the path to file manually:

$ file /dev/fs/C/usr/bin/WSFU/bin/cat
/dev/fs/C/usr/bin/WSFU/bin/cat: Windows NT PE format (EXE), executable not stripped Intel Posix-CUI DOS executable (EXE)


nothing is wrong there either. I can't figure this out, but it seems to have broader implications than just file.

Max
Post #: 1
RE: Strange subshel/path failures - May 25, '06, 10:01:14 PM   
Rodney

 

Posts: 3728
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
Wrong command.
The which command is a csh build-in.
The match command with sh/ksh is whence. Use whence in sh scripts.
Avoid the pathname conversion whenever possible, but if you must then quote it to
protect it from getting interpreted.

If you want you can install an Interix version of which from the warehouse
(pkg_update -L which). But for sh scripts it's better to still use whence.

(in reply to dotequals)
Post #: 2
Page:   [1]
All Forums >> [SFU / Interix / SUA Technology] >> Tools Discussion Forum >> Strange subshel/path failures Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Search All Forums -

Advanced search


SPONSORS



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.031