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"
|
||||
|
||||
local input="$1"
|
||||
if [ -z "$input" ]; then
|
||||
if [ -z "$input" -o "$input" == "-" ]; then
|
||||
input=/dev/stdin
|
||||
elif [ ! -f "$input" ]; then
|
||||
eerror "$input: fichier introuvable"
|
||||
|
@ -1585,14 +1585,26 @@ function lsortcsv() {
|
|||
local padlen=${#padding}
|
||||
local headers
|
||||
|
||||
local -a tmpfiles
|
||||
|
||||
[ "$parse_headers" == "auto" ] && parse_headers=1
|
||||
if [ -n "$parse_headers" ]; then
|
||||
[ -n "$headers" ] || headers="$(<"$input" awkrun skip:int="$skip" 'NR <= skip { next } { print; exit }')"
|
||||
if [ -n "$parse_headers" -a -z "$headers" ]; then
|
||||
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
|
||||
|
||||
# faire le fichier de travail
|
||||
local tmpinput
|
||||
ac_set_tmpfile tmpinput "" __sortcsv_input "" __SORTCSV_DEBUG
|
||||
array_add tmpfiles "$tmpinput"
|
||||
<"$input" >"$tmpinput" awkrun -f \
|
||||
padding="$padding" padlen:int="$padlen" \
|
||||
skip:int="$skip" parse_headers:int="$parse_headers" \
|
||||
|
@ -1616,6 +1628,7 @@ parse_headers && do_once("parse-headers") {
|
|||
# trier le fichier de travail
|
||||
local tmpsorted
|
||||
ac_set_tmpfile tmpsorted "" __sortcsv_sorted "" __SORTCSV_DEBUG
|
||||
array_add tmpfiles "$tmpsorted"
|
||||
args=(# arguments de sort
|
||||
${numeric_sort:+-n} ${ignore_case:+-f}
|
||||
${reverse_sort:+-r} ${stable_sort:+-s}
|
||||
|
@ -1633,7 +1646,7 @@ BEGIN { if (show_headers) print headerscsv }
|
|||
{ print substr($0, padlen + 1) }
|
||||
'
|
||||
|
||||
ac_clean "$tmpinput" "$tmpsorted"
|
||||
ac_clean "${tmpfiles[@]}"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue