Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #212705

Re: Strange Bash Script Problem

From Lee <ler762@gmail.com>
Newsgroups linux.debian.user
Subject Re: Strange Bash Script Problem
Date 2019-08-12 20:00 +0200
Message-ID <yumLU-7mR-5@gated-at.bofh.it> (permalink)
References (1 earlier) <yuiIh-4R4-3@gated-at.bofh.it> <yumiR-7bB-3@gated-at.bofh.it> <yumiR-7bB-1@gated-at.bofh.it> <yumsx-7f0-7@gated-at.bofh.it> <yumCd-7iC-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 8/12/19, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> On Mon, Aug 12, 2019 at 01:37:16PM -0400, Lee wrote:
>> On 8/12/19, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
>> > On Mon, Aug 12, 2019 at 01:19:45PM -0400, Lee wrote:
>> >> On 8/12/19, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
>> >> > P.S. it would also have been possible to work around the carriage
>> >> > return
>> >> > issues with IFS, but your dos2unix approach is perfectly valid as
>> >> > well.
>> >>
>> >> Just out of curiosity - how?
>> >
>> > while IFS=$' \t\r\n' read -r d; do ...
>>
>> Doesn't work for me.  What am I doing wrong?
>>
>> $ sh test
>
> You're running sh.  The $'...' feature I'm using is bash only.
>
>> $ cat test
>> while IFS=$' \t\r\n' read -r d; do
>>   ( cd ${d}_apo || exit
>>     pwd
>>   )
>> done < /tmp/input
>
> Try "bash test" instead of "sh test".

yup -- that was it
$ bash test
/tmp/mydir1_apo
/tmp/mydir2_apo
/tmp/mydir3_apo

>  Also, you want double quotes
> around "${d}_apo", or at least around the "${d}" part.

What's the difference between ${d} and "${d}"?  Or is that a bashism
also? (all my scripts use /bin/sh so I'm pretty clueless wrt bash)

Thanks
Lee

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Strange Bash Script Problem "Stephen P. Molnar" <s.molnar@sbcglobal.net> - 2019-08-11 20:20 +0200
  Re: Strange Bash Script Problem Greg Wooledge <wooledg@eeg.ccf.org> - 2019-08-12 15:40 +0200
    Re: Strange Bash Script Problem "Stephen P. Molnar" <s.molnar@sbcglobal.net> - 2019-08-12 16:30 +0200
    Re: Strange Bash Script Problem Greg Wooledge <wooledg@eeg.ccf.org> - 2019-08-12 19:30 +0200
      Re: Strange Bash Script Problem Lee <ler762@gmail.com> - 2019-08-12 19:40 +0200
        Re: Strange Bash Script Problem Greg Wooledge <wooledg@eeg.ccf.org> - 2019-08-12 19:50 +0200
          Re: Strange Bash Script Problem Lee <ler762@gmail.com> - 2019-08-12 20:00 +0200
            Re: Strange Bash Script Problem Greg Wooledge <wooledg@eeg.ccf.org> - 2019-08-12 20:20 +0200
              Re: Strange Bash Script Problem Lee <ler762@gmail.com> - 2019-08-12 21:10 +0200
                Re: Strange Bash Script Problem David <bouncingcats@gmail.com> - 2019-08-13 02:00 +0200
    Re: Strange Bash Script Problem Lee <ler762@gmail.com> - 2019-08-12 19:30 +0200

csiph-web