Skip to content

Instantly share code, notes, and snippets.

@okraits
Created January 19, 2018 13:21
Show Gist options
  • Save okraits/3e0a14827a619b4f85dcc27cb1df32b1 to your computer and use it in GitHub Desktop.
Save okraits/3e0a14827a619b4f85dcc27cb1df32b1 to your computer and use it in GitHub Desktop.
#!/bin/sh
common_set_list_old() {
local cfg="$1"
local val="$2"
local element list=${val//,/ }
#$UCI_DELETE $cfg
for element in $list; do
echo "$element"
done
return 0
}
common_set_list_new() {
local cfg="$1"
local val="$2"
#$UCI_DELETE $cfg
local oldIFS="$IFS"
IFS=','
for element in $val; do
IFS="$oldIFS"
echo "$element"
done
return 0
}
goodstring="foobar,barfoo"
badstring="foo bar,bar foo"
common_set_list_old "" "$goodstring"
common_set_list_old "" "$badstring"
common_set_list_new "" "$goodstring"
common_set_list_new "" "$badstring"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment