Page 2 of 2

Re: Can't convert image file using a bash script

Posted: 2018-11-12T19:18:37-07:00
by Boogal
snibgo wrote: 2018-11-12T18:32:56-07:00 How did you create the shell script file? If you used Windows tools, line-ends are probably marked with carriage-return and line-feed, but bash normally expects just line-feed, and you need to tell it to ignore carriage-return. See IM with Cygwin: Line ends for workarounds.
This solved it, thanks so much.

edit: a friend told me I should add to this in case any future folks find this googling:

I ended up just adding the following to lines to my bash_profile for cygwin:

Code: Select all

export SHELLOPTS
set -o igncr
to universally ignore carriage returns.

Re: Can't convert image file using a bash script

Posted: 2018-11-12T19:26:06-07:00
by snibgo
Good stuff. I suggest you review all my comments in IM with Cygwin. I documented the problems I found, with solutions, to save other people hitting them.

Re: Can't convert image file using a bash script

Posted: 2018-11-13T10:09:35-07:00
by bratpit
Read what bash telling you.
est.sh: line 3: -4: substring expression < 0
this means bash not allow negative values in substring expansion.
This works in bash > 4.2.
Probably your bash in Cygwin is < 4.2.


Check this parametr expansion:
${1%.*}palette.png
if not this old-school
works in bash, sh, ash, dash, busybox/ash, zsh, ksh, etc.
${1%?}palette.png

Re: Can't convert image file using a bash script

Posted: 2018-11-13T10:30:38-07:00
by bratpit
duplicate prev. post

Re: Can't convert image file using a bash script

Posted: 2018-11-13T10:31:21-07:00
by fmw42
This works on my Mac: ${1%.*}

This does not work on my Mac: ${1::-4}

Unfortunately, Apple provides only older versions of bash on my 2014 Mac Mini. My bash is 3.2.57

Re: Can't convert image file using a bash script

Posted: 2018-11-13T10:40:09-07:00
by bratpit
Fortunatelly there is several ways to do the same in bash :-)