2012/10/18 Keith Marshall <firstname.lastname@example.org>
On 18/10/12 20:13, Renato Silva wrote:I'm sure they would, but hard links are cheaper, and they don't require...
> Thanks! yes, I like the link idea... Yes it is NTFS, but wouldn't symlinks
> work too?
...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).
You can infer the name of the command from the link name itself;
> IIRC it is possible to get symlink name from a linked script (that
> is, to determine which command to call in the wrapper).
something along the lines of:
or, if you need to insert a command specific path:
case $CMD in
bzr) /path/to/$CMD.exe "$@" ;;
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:
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:
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.