diff options
author | Alan Lacerda <alacerda@alpinelinux.org> | 2015-06-05 20:01:43 +0000 |
---|---|---|
committer | Alan Lacerda <alacerda@alpinelinux.org> | 2015-06-05 20:01:43 +0000 |
commit | 9c02681869b3cdcbe577cd20c414291ff01d6c7f (patch) | |
tree | 5639f3ecba6eca0fffbf0d87000360b70aad52a6 | |
parent | f1e8ee7a19d56766dafae355297bb67be80b6917 (diff) | |
download | setup-box-9c02681869b3cdcbe577cd20c414291ff01d6c7f.tar.bz2 setup-box-9c02681869b3cdcbe577cd20c414291ff01d6c7f.tar.xz |
setup-box: useless use of cat
-rwxr-xr-x | setup-box | 35 |
1 files changed, 13 insertions, 22 deletions
@@ -89,20 +89,18 @@ search_files() { search_sub_group() { for f in $json_files; do if [ "${1%.*}" != "desktop" ]; then - if [ $(cat $f | jq ".${1%.*} | length") ]; then + if [ $( < $f jq ".${1%.*} | length") ]; then for j in $@; do core=$(echo $j | cut -d. -f1) sub=$(echo $j | cut -d. -f2) - packages=$(cat $f \ - | jq ".$core[] \ + packages=$( < $f jq ".$core[] \ | select(.$sub)" \ | egrep -Ev '\{|:|]|}' \ | sed 's/\"//g' \ | sed 's/,//g') - services=$(cat $f \ - | jq ".$core[].$sub[].services[]" \ + services=$( < $f jq ".$core[].$sub[].services[]" \ | egrep -Ev '\{|:|]|}' \ | sed 's/\"//g' \ | sed 's/,//g') @@ -119,15 +117,13 @@ search_sub_group() { ## Called by -g option search_meta_group() { for i in $json_files; do - if [ $(cat $i | jq ".$1 | length") ]; then - packages=$(cat $i \ - | jq ".$1[]" \ + if [ $( < $i jq ".$1 | length") ]; then + packages=$( < $i jq ".$1[]" \ | egrep -Ev '\{|:|]|}' \ | sed 's/\"//g' \ | sed 's/,//g') - services=$(cat $i \ - | jq ".$1[][]" \ + services=$( < $i jq ".$1[][]" \ | jq '.[] \ | select(.services)' \ | sed 's/\"//g') @@ -140,18 +136,16 @@ search_meta_group() { ## Called by -d option search_desktop() { - if [ $(cat $desktop_json | jq -e ".desktop[] | select(.$1) | length") ]; then + if [ $( < $desktop_json jq -e ".desktop[] | select(.$1) | length") ]; then # first of all lets force some packages to be installed for i in "base" "drivers"; do - packages=$(cat $desktop_json \ - | jq ".desktop[] \ + packages=$( < $desktop_json jq ".desktop[] \ | select(.$i)" \ | egrep -Ev '\{|:|]|}' \ | sed 's/\"//g' \ | sed 's/,//g') - services=$(cat $desktop_json \ - | jq ".desktop[].$i[].services[]" \ + services=$( < $desktop_json jq ".desktop[].$i[].services[]" \ | sed 's/\"//g') final_pack="$final_pack "$packages @@ -159,15 +153,13 @@ search_desktop() { done # Now lets pick up the packages that we were requested to install - packages=$(cat $desktop_json \ - | jq ".desktop[] \ + packages=$( < $desktop_json jq ".desktop[] \ | select(.$1)" \ | egrep -Ev '\{|:|]|}' \ | sed 's/\"//g' \ | sed 's/,//g') - services=$(cat $desktop_json \ - | jq ".desktop[].$1[].services[]" \ + services=$( < $desktop_json jq ".desktop[].$1[].services[]" \ | sed 's/\"//g') final_pack="$final_pack "$packages @@ -239,8 +231,7 @@ __EOF__ for file in $json_files; do for i in $(echo $file | sed 's/.json//g' | tr ' ' \\n ); do echo $(basename $i): - for sg in $(cat $file \ - | jq '.[][]' \ + for sg in $( < $file jq '.[][]' \ | grep : \ | tr '"' ' ' \ | egrep -v "services|packages" \ @@ -363,4 +354,4 @@ main () { start_services $final_serv } -main $@
\ No newline at end of file +main $@ |