nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] refile and moving sequences with messages


From: Kevin Layer
Subject: Re: [Nmh-workers] refile and moving sequences with messages
Date: Fri, 15 Mar 2013 06:09:28 -0700

Robert Elz wrote:

>>     Date:        Thu, 14 Mar 2013 11:21:32 -0700
>>     From:        Kevin Layer <address@hidden>
>>     Message-ID:  <address@hidden>
>> 
>>   | #! /bin/bash
>> 
>> I see nothing in this that requires bash, so to make it more portable
>> you should probably just use /bin/sh
>> 
>>   | prefix=$(mhpath +inbox | sed 's,/inbox$,,')
>> 
>> This is just         prefix=$(mhpath +)
>> 
>>   | to=$(echo $2 | sed -e "s|^$prefix/||")
>> 
>> And in any reasonably modern shell (certainly including bash)
>> this is just
>>              to=${2#${prefix}/}
>> (and much the same for the assignment to "from" slightly lower).
>> 
>>   |  fromf=$(echo $from | sed -e 's,\(.*\)/\(.*\),\1,')
>> 
>> And this one could be
>>              fromf=${from%/*}
>> (and similar for others using the same pattern).
>> 
>> In general, it is rarely necessary (unless your regular expression is
>> truly complex) to ever do "echo thing | sed" these days, and much safer
>> in case "thing" has any meta characters (like folders with spaces in their
>> names...)
>> 
>>   |  fromm=$(echo $from | sed -e 's,\(.*\)/\(.*\),\2,')
>> 
>> This one is (I think)
>>              fromm=${from##*/}

All good suggestions, which I've incorporated.  Thanks.

>>   |      # Need to set the current folder back to $fromf!
>> 
>> You might want to consider folder -push and folder -pop to
>> better accomplish this.

This one I think is better as is.  If I use folder -push, I need to
specify a folder, which is the same as the one I already specify in
the script, and it's two calls compared to one, as is.

Thanks again!

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]