[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unfamiliar; what does this do: "for file do"..."done"
From: |
Dennis Williamson |
Subject: |
Re: Unfamiliar; what does this do: "for file do"..."done" |
Date: |
Sat, 13 Aug 2016 08:00:15 -0500 |
On Aug 13, 2016 6:36 AM, "L. A. Walsh" <bash@tlinx.org> wrote:
>
> I was looking at how the 'ldd' command(bash script) on my system and
> came across the code usage:
>
> for file do ## about line 138 in my version
> ...
> case $file in
> */* :
> ;;
> *) file=./$file
> ;;
> esac
> ...
> done
>
> It doesn't appear to set the value of file in any of the code
> above the 'for' statement, but is using it in the case statement
> just below the 'for' statement.
>
> As far as I can tell, nothing between the "do" and "done" is
> executed, which as far as I know, would seem to be expected
> behavior. The 1st line of the file has:
>
> #! /bin/bash
>
> indicating bash (v. posix) semantics.
>
> Is there some shell construct that should make this work (execute),
> or is this "effectively" commenting this section out, though still
> processing quotes?
>
> Seems to have been this way for, the past several years leading me
> to think that the code path doesn't get used, or it's using
> some unknown bash functionality.
>
> It looks like it was intended to loop over program arguments left
> over after flag processing, but that's a guess based on the program
> structure.
>
> Any ideas?
>
> Tnx...
> Linda
>
>
>
>
There's an implied in "$@"
for file in "$@"