From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2507 invoked by alias); 21 Feb 2018 21:53:12 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23157 Received: (qmail 4876 invoked by uid 1010); 21 Feb 2018 21:53:12 -0000 X-Qmail-Scanner-Diagnostics: from mta04.eastlink.ca by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(24.224.136.10):SA:0(-2.6/5.0):. Processed in 1.382468 secs); 21 Feb 2018 21:53:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: rayandrews@eastlink.ca X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=utf-8; format=flowed X-Authority-Analysis: v=2.3 cv=dfKuI0fe c=1 sm=1 tr=0 a=RnRVsdTsRxS/hkU0yKjOWA==:117 a=RnRVsdTsRxS/hkU0yKjOWA==:17 a=IkcTkHD0fZMA:10 a=Pube8OPDPsy8yVaTAQgA:9 a=QEXdDO2ut3YA:10 X-EL-IP-NOAUTH: 24.207.101.9 To: Zsh Users From: Ray Andrews Subject: relative path Message-id: <54a8ff5c-cf34-6761-226a-64a5ea9b3730@eastlink.ca> Date: Wed, 21 Feb 2018 13:53:04 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Content-language: en-CA 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.