Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
relative path
Like anyone, when I'm working on something complicated I make copious
backups, and if I find I've introduced some bug I run previous versions
to see where the bug was introduced. But I often have six terminals
openat once, with different versions running here and there and it's
easy to forget which terminal is running which backup, so I do this:
In file 'test' then being backed up to 'test,1' 'test,2' etc:
function my_function ()
{
_vvar=`whence -vS $0 | cut --delimiter=' ' --fields=7-`
_ooutput=`ls -g --time-style=+%F/%T $_vvar | cut --delimiter=' '
--fields=5-`
echo -e "Function: $0 \nFile: $_ooutput"
# code below:
}
$ . ./test; my_function
Function: my_function
File: 2018-02-21/13:07:10 ./test
$ cp test test,2
$ . ./test,2; my_function
Function: my_function
File: 2018-02-21/13:07:20 ./test,2
So, as various copies of the function run I can see the file that was
sourced and its date, and I know which is newer than which. There's just
one small problem and that's if I source the files via a relative path
that path is the one seen by 'whence' and if I run the function out of
the directory where the file is located, whence still sees the relative
path but of course 'ls' now can't find the file. This isn't a big
problem in practice but I'm curious if there would be a solution. Some
way of capturing the absolute path even when I actually use a relative
path. I think there is, I have a niggling I've used it but I can't
remember.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author