summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Lacerda <alacerda@alpinelinux.org>2015-06-05 20:01:43 +0000
committerAlan Lacerda <alacerda@alpinelinux.org>2015-06-05 20:01:43 +0000
commit9c02681869b3cdcbe577cd20c414291ff01d6c7f (patch)
tree5639f3ecba6eca0fffbf0d87000360b70aad52a6
parentf1e8ee7a19d56766dafae355297bb67be80b6917 (diff)
downloadsetup-box-9c02681869b3cdcbe577cd20c414291ff01d6c7f.tar.bz2
setup-box-9c02681869b3cdcbe577cd20c414291ff01d6c7f.tar.xz
setup-box: useless use of cat
-rwxr-xr-xsetup-box35
1 files changed, 13 insertions, 22 deletions
diff --git a/setup-box b/setup-box
index 21343a2..7b70234 100755
--- a/setup-box
+++ b/setup-box
@@ -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 $@