Skip to content

Commit 6f316d1

Browse files
committed
[update] : Bash syntax
1 parent 41d8534 commit 6f316d1

1 file changed

Lines changed: 35 additions & 34 deletions

File tree

tools/menuconf-to-alterconf.sh

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,68 @@
11
#!/usr/bin/env bash
2-
script_path=`dirname $0`
2+
script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && cd .. && pwd )"
33

4-
build_arch=x86_64
4+
build_arch="x86_64"
55

6-
machine_arch=$(uname -m)
7-
cd ${script_path}
8-
if [ $# -ne 1 ]; then
6+
machine_arch="$(uname -m)"
7+
cd "${script_path}"
8+
if [ ${#} -ne 1 ]; then
99
echo "error!" 1>&2
1010
echo "You must set one arg!" 1>&2
1111
exit 1
1212
fi
13+
1314
#build.shのオプションに使う変数を設定
14-
buf=`grep CONFIG_I686_BUILD .config`
15-
eval "$buf"
16-
if [[ $CONFIG_I686_BUILD = "y" ]]; then
15+
buf=$(grep CONFIG_I686_BUILD .config)
16+
eval "${buf}"
17+
if [[ "${CONFIG_I686_BUILD}" = "y" ]]; then
1718
build_arch=i686
1819
fi
1920
buf=`grep CONFIG_KERNEL_N_A_M_E_ .config | sed -e 's/=y//g' | sed -e 's/CONFIG_KERNEL_N_A_M_E_/kernel=/g'`
20-
eval "$buf"
21+
eval "${buf}"
2122
buf=`grep CONFIG_ENABLE_PLYMOUTH .config | sed -e 's/y/true/g' | sed -e 's/CONFIG_ENABLE_PLYMOUTH/plymouth/g'`
22-
eval "$buf"
23+
eval "${buf}"
2324
buf=`grep CONFIG_USE_CUSTOM_LANG .config | sed -e 's/y/true/g' | sed -e 's/CONFIG_USE_CUSTOM_LANG/USE_CUSTOM_LANG/g'`
24-
eval "$buf"
25+
eval "${buf}"
2526
buf=`grep CONFIG_SFS_CMP_ .config | sed -e 's/=y//g' | sed -e 's/CONFIG_SFS_CMP_/comp_type=/g'`
2627
eval "${buf,,}"
2728
buf=`grep CONFIG_USE_SFS_OPTION .config | sed -e 's/y/true/g'`
28-
eval "$buf"
29-
if [[ $CONFIG_USE_SFS_OPTION ]]; then
29+
eval "${buf}"
30+
if [[ "${CONFIG_USE_SFS_OPTION}" ]]; then
3031
if [[ $comp_type = "zstd" ]]; then
3132
buf=`grep CONFIG_ZSTD_COMP_LVL .config`
32-
eval "$buf"
33-
comp_option="-Xcompression-level ${CONFIG_ZSTD_COMP_LVL}"
33+
eval "${buf}"
34+
comp_option="-Xcompression-level '${CONFIG_ZSTD_COMP_LVL}'"
3435
fi
3536
if [[ $comp_type = "gzip" ]]; then
3637
buf=`grep CONFIG_GZIP_SFS_ .config`
37-
eval "$buf"
38-
comp_option="-Xcompression-level ${CONFIG_GZIP_SFS_COMP_LVL} -Xwindow-size ${CONFIG_GZIP_SFS_WIN_SIZE}"
38+
eval "${buf}"
39+
comp_option="-Xcompression-level '${CONFIG_GZIP_SFS_COMP_LVL}' -Xwindow-size '${CONFIG_GZIP_SFS_WIN_SIZE}'"
3940
fi
40-
if [[ $comp_type = "lz4" ]]; then
41+
if [[ "${comp_type}" = "lz4" ]]; then
4142
buf=`grep CONFIG_LZ4_HIGH_COMP .config`
42-
eval "$buf"
43-
if [[ $CONFIG_LZ4_HIGH_COMP = "y" ]]; then
43+
eval "${buf}"
44+
if [[ "${CONFIG_LZ4_HIGH_COMP}" = "y" ]]; then
4445
comp_option="-Xhc"
4546
fi
4647
fi
4748
fi
4849
buf=`grep CONFIG_USE_CUSTOM_USERNAME .config`
49-
eval "$buf"
50-
if [[ $CONFIG_USE_CUSTOM_USERNAME = "y" ]]; then
50+
eval "${buf}"
51+
if [[ "${CONFIG_USE_CUSTOM_USERNAME}" = "y" ]]; then
5152
buf=`grep CONFIG_CUSTOM_USERNAME .config | sed -e 's/CONFIG_CUSTOM_USERNAME/username/g' `
52-
eval "$buf"
53+
eval "${buf}"
5354
fi
5455
buf=`grep CONFIG_USE_CUSTOM_PASSWD .config`
55-
eval "$buf"
56-
if [[ $CONFIG_USE_CUSTOM_PASSWD = "y" ]]; then
56+
eval "${buf}"
57+
if [[ "${CONFIG_USE_CUSTOM_PASSWD}" = "y" ]]; then
5758
buf=`grep CONFIG_CUSTOM_PASSWD .config | sed -e 's/CONFIG_CUSTOM_PASSWD/password/g' `
58-
eval "$buf"
59+
eval "${buf}"
5960
fi
6061
buf=`grep CONFIG_CHANNEL_ .config | sed -e 's/=y//g' | sed -e 's/CONFIG_CHANNEL_/channel=/g'`
6162
eval "${buf,,}"
6263
if [[ $USE_CUSTOM_LANG = "true" ]]; then
6364
buf=`grep CONFIG_CUSTOM_LANGUAGE .config | sed -e 's/CONFIG_CUSTOM_LANGUAGE/language/g' `
64-
eval "$buf"
65+
eval "${buf}"
6566
fi
6667

6768
echo build option :
@@ -74,26 +75,26 @@ echo build option :
7475
[[ -n "${password}" ]] && echo " Password : ${password}"
7576
[[ -n "${channel}" ]] && echo " Channel : ${channel}"
7677

77-
if [[ ${USE_CUSTOM_LANG} = "true" ]]; then
78+
if [[ "${USE_CUSTOM_LANG}" = "true" ]]; then
7879
argument="${argument} -g ${language}"
7980
fi
80-
if [[ ${plymouth} = true ]]; then
81+
if [[ "${plymouth}" = true ]]; then
8182
argument="${argument} -b"
8283
fi
83-
if [[ -n ${comp_type} ]]; then
84+
if [[ -n "${comp_type}" ]]; then
8485
argument="${argument} -c ${comp_type}"
8586
fi
86-
if [[ -n ${kernel} ]]; then
87+
if [[ -n "${kernel}" ]]; then
8788
argument="${argument} -k ${kernel}"
8889
fi
8990
if [[ -n "${username}" ]]; then
9091
argument="${argument} -u '${username}'"
9192
fi
92-
if [[ -n ${password} ]]; then
93+
if [[ -n "${password}" ]]; then
9394
argument="${argument} -p '${password}'"
9495
fi
95-
if [[ -n ${out_dir} ]]; then
96+
if [[ -n "${out_dir}" ]]; then
9697
argument="${argument} -o '${out_dir}'"
9798
fi
9899
argument="-a ${build_arch} --noconfirm ${argument} ${channel}"
99-
echo $argument > $1
100+
echo "${argument}" > "${1}"

0 commit comments

Comments
 (0)