Web lists-archives.com

Re: bash command substitution




Hello,

it was compiled with mingw, and the \r was the issue, thanks!

---
Köszönettel:
Vukovics Mihály

On 2017-10-01 19:54, Brian Inglis wrote:
On 2017-10-01 00:40, Vukovics Mihaly wrote:
I just wanted to use my bash script written in Debian 8 in cygwin(latest, win10
64bit), but does not work.
At a specific line there is a command substitution trying to get result from
ffprobe:
VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of
default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
For debugging purpose the same command is executed without putting the result into a variable, and works! Does anyone know why is it not working in cygwin?
Code:
...
declare -i VHEIGHT
ffprobe -v error -show_entries stream=width,height -of
default=noprint_wrappers=1 ${OLDFILE} | grep height | cut -f2 -d'='
VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of
default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
...
Here is some debug log (set -x):
....
+ declare -i VHEIGHT
+ ffprobe -v error -show_entries stream=width,height -of
default=noprint_wrappers=1 P1220312.MP4
+ grep height
+ cut -f2 -d=
2160              # this woudl be the desired value
+ VHEIGHT=        # here the variable is empty!
+ VIDSTABDETECTOPTS=:shakiness=10
+ VIDSTABDETECTOPTS+=:result=P1220312-stab.trf
+ VIDSTABTRANSFORMOPTS+=:crop=keep
....
The same in Linux bash:
...
+ declare -i VHEIGHT
+ ffprobe -v error -show_entries stream=width,height -of
default=noprint_wrappers=1 P1220312.MP4
+ grep height
+ cut -f2 -d=
2160
++ ffprobe -v error -show_entries stream=width,height -of
default=noprint_wrappers=1 P1220312.MP4
++ grep height
++ cut -f2 -d=
+ VHEIGHT=2160     # here is the desired value in the variable!!!
...
Any suggestions?

Non-numeric characters in string - add "| cat -A" to the end of your pipe,
or equivalent od or xxd commands to see what's there.
There is no Cygwin package so how was ffprobe built - with Cygwin or Mingw? May be extraneous trailing spaces or \r at end of input - try "set -o igncr".

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple