2012/10/18 Keith Marshall <keithmarshall@users.sourceforge.net>
On 18/10/12 20:13, Renato Silva wrote:
> Thanks! yes, I like the link idea... Yes it is NTFS, but wouldn't symlinks
> work too?

I'm sure they would, but hard links are cheaper, and they don't require...

> Windows 7 supports them out-of-the-box, while in XP I think I can
> use
Link Shell Extension (
>http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html#symboliclinksforwindowsxp
> ).

...any such support from the operating system, (nor from any add-on).
OTOH, hard links can only be used with physical disk files, and they
cannot span devices, (neither of which represents a problem in the
scenario under discussion).

> IIRC it is possible to get symlink name from a linked script (that
> is, to determine which command to call in the wrapper).

You can infer the name of the command from the link name itself;
something along the lines of:

   #!/bin/sh
   CMD=`basename "$0"`
   $CMD.exe "$@"

or, if you need to insert a command specific path:

   #!/bin/sh
   CMD=`basename "$0"`
   case $CMD in
     bzr) /path/to/$CMD.exe "$@" ;;
     ...
   esac

should do the trick, for either hard links or for symlinks.


Thanks, I didn't know or remember basename worked for links. So I have implemented something better than aliases with a script called /local/bin/runcrt.sh:

#!/bin/bash
env -u TZ $(basename "$0").exe "$@"

Then I created symlinks, ruby, python and bzr for now, pointing to that script. They work, except for ruby, which is used in /etc/profile exactly to build value for TZ (through my posix-brst.rb script). When called from path in profile, ruby will run as a bash script (runcrt.sh), which for some reason causes /etc/profile, and even ~/.profile, and even on BASH_ENV="/not/etc/profile", to be recursively sourced, leading to bash not starting at all and adding a growing list of processes in task manager.

My workaround was to rather call the raw ruby executable directly in /etc/profile, like this:
rubyexe="/C/Programs/Desenvolvimento/Ruby/bin/ruby"
export TZ="BRT+3BRST$($rubyexe /local/bin/posix-brst.rb)"
 
Now I'm curious on a way to run a bash script from one of the initialization scripts, without causing the bash initialization process to become recursive. I'm curious too about my "H" timezone returned by Windows API. Also, I think I'll try later to switch to the opposite approach, that is, using symlinks like ls and date to something like tzrun.sh (even though I would prefer to find a solution for the recursive problem, in case ls, date, and others get ever called from within initialization scripts).

So, still seeking for information and solutions.
Regards.

--
Regards,
Keith.

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
MinGW-users mailing list
MinGW-users@lists.sourceforge.net

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@lists.sourceforge.net?subject=unsubscribe