简体   繁体   中英

PyBugz Bash Variables \n newline is ignored

i have a bash script, that extracts the bugs from a csv file and imports it into bugzilla using PyBugz.

The following sequences are used:

description=$(echo "$line" |cut -f5 -d ';')
bugz -d 3 -b http://bugzilla/bugzilla/xmlrpc.cgi -u "$user" -p "$pass" post --product "$prod" --component "$compo" --title "$title" --description "$description" --op-sys "$ops" --platform "$platf" --priority ""$prio"" --severity "$sever" --alias "$alias" --assigned-to "$assign" --cc "$ccl" --version "$ver" --url "$url" --append-command "$appen" --default-confirm "y"

but the description line containing "blablabla \\n blablabla" including the newline is beeing recognized as

"Description : blablabla n blablabla"

If I export a bug and dump the output into a textfile, pybugz puts a 0x0a as newline character. how can I make pybugz recognize my \\n character as 0x0a??

If description contains the characters \\ n , and you want to convert that into an actual newline, then you'll have to do some work:

bugz ... --description "$(echo -e "$description")" ...

That will expose other escape sequences as well, see https://www.gnu.org/software/bash/manual/bashref.html#index-echo

I got it.

The way to catch the data was done in the following way:

while read line ; do
description=$(echo "$line" |cut -f5 -d ';')
done <csvfile

however, the read already changed the \\n string to n so whatever I did after that was obviously a failure.

I did it in a very unnice way now but it works like a charm

lines=$(cat csvexport |wc -l)
for (( lineno=1 ; $lineno<=$lines ; lineno++ )); do
description=$(cat csvexport |sed -n "$lineno"p |cut -f5 -d ';')
done

and everything is fine ;-) Thanks anyway for the help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM