Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: MP3 Managing Tool?

Re: MP3 Managing Tool?

From: Neon John <johngd_at_bellsouth.net>
Date: 2005-01-15

On Fri, 14 Jan 2005 15:15:58 -0800, Menachem Shapiro
<menachem.shapiro@gmail.com> wrote:

>----script excerpt--------
> for f in `ls "$MOUNT"|sed 's/ /_-_-_/g'`; do
> f=`echo "$f"|sed 's/_-_-_/ /g'`
> echo "cp $f -> $TARGET"
> cp "$f" "$TARGET" 2>/dev/null >&1 || faildo "$f"
> unset f
> done
>--------end excerpt--------
>
>Is it standard practice to use the same variable ('f') as the variable
>used for the for loop? I noticed it gets unset at the end, but it
>seems a little scary.

Perfectly normal. the loop runs until the list produced by the ls |sed
pipe is exhausted, then exits. When the list is exhausted, f is not
assigned anything. The unset leaves f with a null string which is FALSE
in the "for" conditional.

I can't think of any easier way to do that in a shell script. Clever.

John

---
John De Armond
johngdDONTYOUDARE@bellsouth.net
http://bellsouthpwp.net/j/o/johngd/
Cleveland, Occupied TN
_______________________________________________
http://cool.haxx.se/mailman/listinfo/rockbox
Received on Sat Jan 15 00:33:04 2005

Page was last modified "Jan 10 2012" The Rockbox Crew
aaa