@@ -174,11 +174,11 @@ valopt() {
174
174
eval $v =" $default "
175
175
for arg in $CFG_ARGS
176
176
do
177
- if echo " $ arg" | grep -q -- " -- $op = "
178
- then
179
- local val=$( echo " $ arg" | cut -f2 -d= )
180
- eval $v =$val
181
- fi
177
+ case " ${ arg} " in
178
+ " -- ${op} = " * )
179
+ local val=" ${ arg# -- ${op} =} "
180
+ eval $v =$val
181
+ esac
182
182
done
183
183
putvar $v
184
184
else
@@ -280,10 +280,10 @@ validate_opt () {
280
280
done
281
281
for option in $VAL_OPTIONS
282
282
do
283
- if echo " $ arg" | grep -q -- " -- $option = "
284
- then
285
- is_arg_valid=1
286
- fi
283
+ case " ${ arg} " in
284
+ " -- ${option} = " * )
285
+ is_arg_valid=1
286
+ esac
287
287
done
288
288
if [ " $arg " = " --help" ]
289
289
then
@@ -302,8 +302,8 @@ validate_opt () {
302
302
303
303
absolutify () {
304
304
local file_path=" $1 "
305
- local file_path_dirname=" $( dirname " $ file_path" ) "
306
- local file_path_basename=" $( basename " $ file_path" ) "
305
+ local file_path_dirname=" ${ file_path%/* } "
306
+ local file_path_basename=" ${ file_path##*/ } "
307
307
local file_abs_path=" $( abs_path " $file_path_dirname " ) "
308
308
local file_path=" $file_abs_path /$file_path_basename "
309
309
# This is the return value
@@ -442,8 +442,8 @@ uninstall_components() {
442
442
local _directive
443
443
while read _directive; do
444
444
445
- local _command=` echo $ _directive | cut -f1 -d: `
446
- local _file=` echo $ _directive | cut -f2 -d: `
445
+ local _command=" ${ _directive%%:* } "
446
+ local _file=" ${ _directive#*: } "
447
447
448
448
# Sanity checks
449
449
if [ ! -n " $_command " ]; then critical_err " malformed installation directive" ; fi
@@ -549,8 +549,8 @@ install_components() {
549
549
local _directive
550
550
while read _directive; do
551
551
552
- local _command=` echo $ _directive | cut -f1 -d: `
553
- local _file=` echo $ _directive | cut -f2 -d: `
552
+ local _command=" ${ _directive%%:* } "
553
+ local _file=" ${ _directive#*: } "
554
554
555
555
# Sanity checks
556
556
if [ ! -n " $_command " ]; then critical_err " malformed installation directive" ; fi
@@ -559,35 +559,23 @@ install_components() {
559
559
# Decide the destination of the file
560
560
local _file_install_path=" $_dest_prefix /$_file "
561
561
562
- if echo " $_file " | grep " ^etc/" > /dev/null
563
- then
564
- local _f=" $( echo " $_file " | sed ' s/^etc\///' ) "
565
- _file_install_path=" $CFG_SYSCONFDIR /$_f "
566
- fi
567
-
568
- if echo " $_file " | grep " ^bin/" > /dev/null
569
- then
570
- local _f=" $( echo " $_file " | sed ' s/^bin\///' ) "
571
- _file_install_path=" $CFG_BINDIR /$_f "
572
- fi
573
-
574
- if echo " $_file " | grep " ^lib/" > /dev/null
575
- then
576
- local _f=" $( echo " $_file " | sed ' s/^lib\///' ) "
577
- _file_install_path=" $CFG_LIBDIR /$_f "
578
- fi
579
-
580
- if echo " $_file " | grep " ^share" > /dev/null
581
- then
582
- local _f=" $( echo " $_file " | sed ' s/^share\///' ) "
583
- _file_install_path=" $CFG_DATADIR /$_f "
584
- fi
585
-
586
- if echo " $_file " | grep " ^share/man/" > /dev/null
587
- then
588
- local _f=" $( echo " $_file " | sed ' s/^share\/man\///' ) "
589
- _file_install_path=" $CFG_MANDIR /$_f "
590
- fi
562
+ case " ${_file} " in
563
+ etc/* )
564
+ _file_install_path=" $CFG_SYSCONFDIR /${_file# etc/ } "
565
+ ;;
566
+ bin/* )
567
+ _file_install_path=" $CFG_BINDIR /${_file# bin/ } "
568
+ ;;
569
+ lib/* )
570
+ _file_install_path=" $CFG_LIBDIR /${_file# lib/ } "
571
+ ;;
572
+ share/man/* )
573
+ _file_install_path=" $CFG_MANDIR /${_file# share/ man/ } "
574
+ ;;
575
+ share/* )
576
+ _file_install_path=" $CFG_DATADIR /${_file# share/ } "
577
+ ;;
578
+ esac
591
579
592
580
# HACK: Try to support overriding --docdir. Paths with the form
593
581
# "share/doc/$product/" can be redirected to a single --docdir
@@ -601,15 +589,14 @@ install_components() {
601
589
# this problem to be a big deal in practice.
602
590
if [ " $CFG_DOCDIR " != " <default>" ]
603
591
then
604
- if echo " $_file " | grep " ^share/doc/" > /dev/null
605
- then
606
- local _f=" $( echo " $_file " | sed ' s/^share\/doc\/[^/]*\///' ) "
607
- _file_install_path=" $CFG_DOCDIR /$_f "
608
- fi
592
+ case " ${_file} " in
593
+ share/doc/* )
594
+ _file_install_path=" $CFG_DOCDIR /${_file# share/ doc/*/ } "
595
+ esac
609
596
fi
610
597
611
598
# Make sure there's a directory for it
612
- make_dir_recursive " $( dirname " $ _file_install_path" ) "
599
+ make_dir_recursive " ${ _file_install_path%/* } "
613
600
critical_need_ok " directory creation failed"
614
601
615
602
# Make the path absolute so we can uninstall it later without
@@ -625,7 +612,7 @@ install_components() {
625
612
626
613
maybe_backup_path " $_file_install_path "
627
614
628
- if echo " $ _file" | grep " ^ bin/" > /dev/null || test -x " $_src_dir /$_component /$_file "
615
+ if test -z " ${ _file## bin/* } " || test -x " $_src_dir /$_component /$_file "
629
616
then
630
617
run cp " $_src_dir /$_component /$_file " " $_file_install_path "
631
618
run chmod 755 " $_file_install_path "
@@ -770,8 +757,6 @@ verbose_msg
770
757
771
758
need_cmd mkdir
772
759
need_cmd printf
773
- need_cmd cut
774
- need_cmd grep
775
760
need_cmd uname
776
761
need_cmd tr
777
762
need_cmd sed
0 commit comments