[NTLUG:Discuss] Auto-completion within a bash script?

Val Harris valwharris at verizon.net
Thu Apr 16 14:33:55 CDT 2009


Lance Simmons wrote:
> On Thu, Apr 16, 2009 at 12:23 PM, Eric Waguespack <ewaguespack at gmail.com> wrote:
>> I am not aware of any way to allow auto completion in a bash script,
>> (at the read prompt).
> [...]
>> change
>> read ATTACHMENT
>> to
>> ATTACHMENT="$1"
>> then you would have your auto completion, though it would be at script
>> initiation, not during execution.
> 
> That was how I did it in the past, but the problem was that I kept
> forgetting in what order to place the four arguments (file with list
> of addresses, file with message, subject heading, and, if
> appropriate, attachment file).  The two important ones are the
> message file and the attachment file, so maybe I should use two
> (auto-completed) arguments and then two read prompts for the
> list of addresses and the subject line.

How about using option letters for each file ( -r <recipients> -m 
<message> -s <subject> and -a <attachment>).  If -a is the only optional 
argument, your order issue is solved.

-- 
Val W. Harris                    valwharris at verizon.net

"Beware of all enterprises that require new clothes."
  - Henry David Thoreau




More information about the Discuss mailing list