[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] checking file line: 'commit;'
From: |
Paolo Supino |
Subject: |
Re: [Help-bash] checking file line: 'commit;' |
Date: |
Thu, 11 Aug 2016 17:17:35 +0200 |
Hi Greg
I don't dislike case, I usually use it when I have 4 or more options :-)
I did a little test and put 'commit;\r' and the team leader didn't seem to
notice the difference... So I've put 'commit;'$'\r' and he came back asking
what's that? I explained and now he wants to go to the project manager to
talk about the brain dead windows crap we have to deal with :-)
Paolo
On Thu, Aug 11, 2016 at 5:08 PM, Greg Wooledge <address@hidden> wrote:
> On Thu, Aug 11, 2016 at 04:55:33PM +0200, Paolo Supino wrote:
> > You're right... The file were originally written in Windows and there's
> > Windows garbage (carriage return) follows 'commit;' string :-( Changing
> the
> > check to 'commit;'$'\r' fixes the problem...
>
> First point: you can write that as $'commit;\r'
>
> Second point: in the future, the carriage return may not always be
> present. So you probably want a check like:
>
> if [[ $string = $'commit;' || $string = $'commit;\r' ]]
>
> Of course there are many other ways to write it. I'd use case myself,
> but you seem to dislike it, so here's one using [[ and ||.
>