bug dans sortcsv
This commit is contained in:
parent
f20f9ee4eb
commit
add0060245
|
@ -1 +1 @@
|
||||||
40
|
41
|
||||||
|
|
21
ulib/awk
21
ulib/awk
|
@ -1574,7 +1574,7 @@ function lsortcsv() {
|
||||||
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
||||||
|
|
||||||
local input="$1"
|
local input="$1"
|
||||||
if [ -z "$input" ]; then
|
if [ -z "$input" -o "$input" == "-" ]; then
|
||||||
input=/dev/stdin
|
input=/dev/stdin
|
||||||
elif [ ! -f "$input" ]; then
|
elif [ ! -f "$input" ]; then
|
||||||
eerror "$input: fichier introuvable"
|
eerror "$input: fichier introuvable"
|
||||||
|
@ -1585,14 +1585,26 @@ function lsortcsv() {
|
||||||
local padlen=${#padding}
|
local padlen=${#padding}
|
||||||
local headers
|
local headers
|
||||||
|
|
||||||
|
local -a tmpfiles
|
||||||
|
|
||||||
[ "$parse_headers" == "auto" ] && parse_headers=1
|
[ "$parse_headers" == "auto" ] && parse_headers=1
|
||||||
if [ -n "$parse_headers" ]; then
|
if [ -n "$parse_headers" -a -z "$headers" ]; then
|
||||||
[ -n "$headers" ] || headers="$(<"$input" awkrun skip:int="$skip" 'NR <= skip { next } { print; exit }')"
|
if [ "$input" == /dev/stdin ]; then
|
||||||
|
# Si on lit depuis stdin, il faut faire une copie du flux dans un
|
||||||
|
# fichier temporaire pour calculer les en-têtes
|
||||||
|
local tmpinput
|
||||||
|
ac_set_tmpfile tmpinput "" __sortcsv_input0 "" __SORTCSV_DEBUG
|
||||||
|
array_add tmpfiles "$tmpinput"
|
||||||
|
cat >"$tmpinput"
|
||||||
|
input="$tmpinput"
|
||||||
|
fi
|
||||||
|
headers="$(<"$input" awkrun skip:int="$skip" 'NR <= skip { next } { print; exit }')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# faire le fichier de travail
|
# faire le fichier de travail
|
||||||
local tmpinput
|
local tmpinput
|
||||||
ac_set_tmpfile tmpinput "" __sortcsv_input "" __SORTCSV_DEBUG
|
ac_set_tmpfile tmpinput "" __sortcsv_input "" __SORTCSV_DEBUG
|
||||||
|
array_add tmpfiles "$tmpinput"
|
||||||
<"$input" >"$tmpinput" awkrun -f \
|
<"$input" >"$tmpinput" awkrun -f \
|
||||||
padding="$padding" padlen:int="$padlen" \
|
padding="$padding" padlen:int="$padlen" \
|
||||||
skip:int="$skip" parse_headers:int="$parse_headers" \
|
skip:int="$skip" parse_headers:int="$parse_headers" \
|
||||||
|
@ -1616,6 +1628,7 @@ parse_headers && do_once("parse-headers") {
|
||||||
# trier le fichier de travail
|
# trier le fichier de travail
|
||||||
local tmpsorted
|
local tmpsorted
|
||||||
ac_set_tmpfile tmpsorted "" __sortcsv_sorted "" __SORTCSV_DEBUG
|
ac_set_tmpfile tmpsorted "" __sortcsv_sorted "" __SORTCSV_DEBUG
|
||||||
|
array_add tmpfiles "$tmpsorted"
|
||||||
args=(# arguments de sort
|
args=(# arguments de sort
|
||||||
${numeric_sort:+-n} ${ignore_case:+-f}
|
${numeric_sort:+-n} ${ignore_case:+-f}
|
||||||
${reverse_sort:+-r} ${stable_sort:+-s}
|
${reverse_sort:+-r} ${stable_sort:+-s}
|
||||||
|
@ -1633,7 +1646,7 @@ BEGIN { if (show_headers) print headerscsv }
|
||||||
{ print substr($0, padlen + 1) }
|
{ print substr($0, padlen + 1) }
|
||||||
'
|
'
|
||||||
|
|
||||||
ac_clean "$tmpinput" "$tmpsorted"
|
ac_clean "${tmpfiles[@]}"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue