File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -542,6 +542,50 @@ iterate() (
542
542
fi
543
543
) # _____________________________________________________________________
544
544
545
+
546
+
547
+ # _______________________________________________________________________
548
+ # |__ csvline ____________________________________________________________|
549
+ #
550
+ # csvline [-d delimiter] [-D line-delimiter]
551
+ #
552
+ # Parse a CSV record from standard input, storing the fields in the CSVLINE array.
553
+ #
554
+ # By default, a single line of input is read and parsed into comma-delimited fields.
555
+ # Fields can optionally contain double-quoted data, including field delimiters.
556
+ #
557
+ # A different field delimiter can be specified using -d. You can use -D
558
+ # to change the definition of a "record" (eg. to support NULL-delimited records).
559
+ #
560
+ csvline () {
561
+ CSVLINE=()
562
+ local line field quoted=0 delimiter=, lineDelimiter=$' \n ' c
563
+ local OPTIND=1 arg
564
+ while getopts :d: arg; do
565
+ case $arg in
566
+ d) delimiter=$OPTARG ;;
567
+ esac
568
+ done
569
+
570
+ IFS= read -d " $lineDelimiter " -r line || return
571
+ while IFS= read -rn1 c; do
572
+ case $c in
573
+ \" )
574
+ (( quoted = ! quoted ))
575
+ continue ;;
576
+ $delimiter )
577
+ if (( ! quoted )) ; then
578
+ CSVLINE+=( " $field " ) field=
579
+ continue
580
+ fi ;;
581
+ esac
582
+ field+=$c
583
+ done <<< " $line"
584
+ [[ $field ]] && CSVLINE+=( " $field " ) || :
585
+ } # _____________________________________________________________________
586
+
587
+
588
+
545
589
# ______________________________________________________________________
546
590
# |__ Logging ___________________________________________________________|
547
591
#
Original file line number Diff line number Diff line change 8
8
sys.stdout.flush()
9
9
except IOError:
10
10
pass
11
- ' | PlistBuddy -c Print -
11
+ '
You can’t perform that action at this time.
0 commit comments