Jan 25, 2005 #1 cantubas Programmer Jan 8, 2004 45 FR in shell script unix I do echo $(cd $(dirname "$name");pwd)/$(basename "$name") is it possible in C?? escuse me for my bad english, I'm french
in shell script unix I do echo $(cd $(dirname "$name");pwd)/$(basename "$name") is it possible in C?? escuse me for my bad english, I'm french
Jan 26, 2005 #2 Salem Programmer Apr 29, 2003 2,455 GB Exactly how is that different to this? Code: echo $name I mean the 'cd' happens in a sub-shell, so the side-effect of that is lost. -- Upvote 0 Downvote
Exactly how is that different to this? Code: echo $name I mean the 'cd' happens in a sub-shell, so the side-effect of that is lost. --
Jan 26, 2005 Thread starter #3 cantubas Programmer Jan 8, 2004 45 FR $ pwd /usr/bin $ name="sh" $ echo $(cd $(dirname "$name");pwd)/$(basename "$name") /usr/bin/sh $ echo $name sh do you anderstand?? Upvote 0 Downvote
$ pwd /usr/bin $ name="sh" $ echo $(cd $(dirname "$name");pwd)/$(basename "$name") /usr/bin/sh $ echo $name sh do you anderstand??
Jan 26, 2005 #4 Salem Programmer Apr 29, 2003 2,455 GB So it's this then? Code: echo `pwd`/$name Or were you hoping to get "/usr/bin/sh" even when the current directory isn't /usr/bin? This sounds exactly like the "which" command. What other examples of pwd and $name do you have to worry about? Stating the problem rather than your current answer would be a help as well. -- Upvote 0 Downvote
So it's this then? Code: echo `pwd`/$name Or were you hoping to get "/usr/bin/sh" even when the current directory isn't /usr/bin? This sounds exactly like the "which" command. What other examples of pwd and $name do you have to worry about? Stating the problem rather than your current answer would be a help as well. --
Jan 26, 2005 Thread starter #5 cantubas Programmer Jan 8, 2004 45 FR i want a C function that can translate any relative name (like ../bin/sh) into absolute name (like /usr/bin/sh) i want a C solution if it's possible ===================================== Upvote 0 Downvote
i want a C function that can translate any relative name (like ../bin/sh) into absolute name (like /usr/bin/sh) i want a C solution if it's possible =====================================
Jan 26, 2005 #6 Salem Programmer Apr 29, 2003 2,455 GB Oh, you mean like realpath -- Upvote 0 Downvote