remove newlines from elements
This commit is contained in:
parent
9a3090b6b2
commit
856d5172eb
@ -2,14 +2,19 @@ function g_array {
|
||||
local g_filename=$1
|
||||
local g_arrayname=$2
|
||||
local g_delimeter=$3
|
||||
local g_array
|
||||
|
||||
[ -n "$g_delimeter" ] && g_delimeter="-d${g_delimeter}"
|
||||
if [ -f "$g_filename" ]
|
||||
then
|
||||
mapfile $g_delimeter -tn 0 $g_arrayname < "$g_filename"
|
||||
mapfile $g_delimeter -tn 0 g_array < "$g_filename"
|
||||
else
|
||||
mapfile $g_delimeter -tn 0 $g_arrayname <<< "$g_filename"
|
||||
mapfile $g_delimeter -tn 0 g_array <<< "$g_filename"
|
||||
fi
|
||||
|
||||
# remove newlines
|
||||
g_array=("${g_array[@]%$'\n'}")
|
||||
declare -n $g_arrayname=g_array
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user