Re: [dev] [dmenu] dmenu_run improvements

From: Anselm R Garbe <garbeam_AT_gmail.com>
Date: Sun, 24 Jul 2011 10:06:43 +0100

On 24 July 2011 09:57, lolilolicon <lolilolicon_AT_gmail.com> wrote:
> On Sun, Jul 24, 2011 at 4:39 PM, Anselm R Garbe <garbeam_AT_gmail.com> wrote:
>> On 24 July 2011 06:34, Dave Reisner <d_AT_falconindy.com> wrote:
>>> #!/bin/sh
>>>
>>> CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
>>> IFS=:
>>> LC_COLLLATE=C
>>>
>>> gencache() {
>>>  lsx $PATH | sort -u >"$CACHE"
>>> }
>>>
>>> if [ ! -e "$CACHE" ]; then
>>>  mkdir -p "${CACHE%/*}"
>>>  gencache
>>> fi
>>>
>>> for path in $PATH; do
>>>  if [ "$path" -nt "$CACHE" ]; then
>>>    gencache
>>>    break
>>>  fi
>>> done
>>
>> Am I right that the previous loop runs gencache n times, under the
>> assumption that each path component contains newer files?
>>
>> Kind regards,
>> Anselm
>
> No, note the `break'.

True, I must have been half asleep when I glanced at that loop...

Nevertheless, I can see that script should be improved (not using the
ls -dt invocation), but I prefer the back ticks (even if $(..) is
POSIX, there were a couple of issues in the past that I barely
remember) and I want explicit test calls, I don't like the [ ... ]
syntax sugar.

Thanks,
Anselm
Received on Sun Jul 24 2011 - 11:06:43 CEST

This archive was generated by hypermail 2.2.0 : Sun Jul 24 2011 - 11:12:03 CEST