fix read_nullbyte() to avoid trimming whitespace v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 11 Jan 2020 20:24:43 +0100
branchv_0
changeset 290 e73765513aec
parent 289 34a7c4e318b3
child 291 2fab532bda09
fix read_nullbyte() to avoid trimming whitespace
relpipe-data/examples-in-xmltable-xhtml-outline.xml
relpipe-data/examples-out-bash.xml
--- a/relpipe-data/examples-in-xmltable-xhtml-outline.xml	Sat Jan 04 20:21:45 2020 +0100
+++ b/relpipe-data/examples-in-xmltable-xhtml-outline.xml	Sat Jan 11 20:24:43 2020 +0100
@@ -113,7 +113,7 @@
 		<m:pre jazyk="bash"><![CDATA[# our favorite function used also in other examples;
 # reads values separated by a \0 byte into a variable;
 # this is a safer way than a space or newline separated data:
-read_nullbyte() { for v in "$@"; do export "$v"; read -r -d '' "$v"; done }
+read_nullbyte() { local IFS=; for v in "$@"; do export "$v"; read -r -d '' "$v"; done }
 
 wget -O - http://blog.frantovo.cz/ \
 	| relpipe-in-xmltable \
--- a/relpipe-data/examples-out-bash.xml	Sat Jan 04 20:21:45 2020 +0100
+++ b/relpipe-data/examples-out-bash.xml	Sat Jan 11 20:24:43 2020 +0100
@@ -19,7 +19,7 @@
 			We will define a function that will help us with reading the <code>\0</code>-separated values and putting them into shell variables:
 		</p>
 		
-		<m:pre jazyk="bash"><![CDATA[read_nullbyte() { for v in "$@"; do export "$v"; read -r -d '' "$v"; done }]]></m:pre>
+		<m:pre jazyk="bash"><![CDATA[read_nullbyte() { local IFS=; for v in "$@"; do export "$v"; read -r -d '' "$v"; done }]]></m:pre>
 		
 		<!--
 			This version will not require the last \0: