From: Ray Andrews <rayandrews@eastlink.ca>
To: Zsh Users <zsh-users@zsh.org>
Subject: relative path
Date: Wed, 21 Feb 2018 13:53:04 -0800 [thread overview]
Message-ID: <54a8ff5c-cf34-6761-226a-64a5ea9b3730@eastlink.ca> (raw)
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.
next reply other threads:[~2018-02-21 21:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 21:53 Ray Andrews [this message]
2018-02-22 2:16 ` Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54a8ff5c-cf34-6761-226a-64a5ea9b3730@eastlink.ca \
--to=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).