[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] checking file line: 'commit;'
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] checking file line: 'commit;' |
Date: |
Thu, 11 Aug 2016 11:08:09 -0400 |
User-agent: |
Mutt/1.4.2.3i |
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 ||.