Skip to content

Commit 1682666

Browse files
committed
pkg: improve contect
1 parent 685f56a commit 1682666

File tree

1 file changed

+9
-8
lines changed
  • packages/termux-tools

1 file changed

+9
-8
lines changed

packages/termux-tools/pkg

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fi
77

88
show_help() {
99
local cache_size
10-
local cache_dir
10+
local cache_dir=""
1111
if [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" ]; then
1212
cache_dir="@TERMUX_CACHE_DIR@/apt/archives"
1313
elif [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" ]; then
@@ -189,18 +189,17 @@ update_apt_cache() {
189189
fi
190190
}
191191

192-
if [ $# = 0 ]; then
192+
if [[ $# = 0 || $(echo "$1" | grep "^h") ]]; then
193193
show_help
194194
fi
195195

196196
CMD="$1"
197-
WRITE_ERROR=false
197+
ERROR=false
198198
shift 1
199199

200200
if [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" ]; then
201201
case "$CMD" in
202202
f*) dpkg -L "$@";;
203-
h*) show_help;;
204203
sh*|inf*) apt show "$@";;
205204
add|i*)
206205
select_mirror
@@ -223,12 +222,11 @@ if [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" ]; then
223222
apt update
224223
apt full-upgrade "$@"
225224
;;
226-
*) WRITE_ERROR=true;;
225+
*) ERROR=true;;
227226
esac
228227
elif [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" ]; then
229228
case "$CMD" in
230229
f*) pacman -Ql "$@";;
231-
h*) show_help;;
232230
sh*|inf*) pacman -Qi "$@";;
233231
add|i*) pacman -Sy "$@" --needed;;
234232
autoc*) pacman -Sc --noconfirm;;
@@ -239,11 +237,14 @@ elif [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "pacman" ]; then
239237
se*) pacman -Sys "$@";;
240238
un*|rem*|rm|del*) pacman -Rcns "$@";;
241239
up*) pacman -Syu;;
242-
*) WRITE_ERROR=true;;
240+
*) ERROR=true;;
243241
esac
242+
else
243+
echo "Error: pkg is not supported with '$TERMUX_MAIN_PACKAGE_FORMAT' package manager format"
244+
exit 1
244245
fi
245246

246-
if $WRITE_ERROR; then
247+
if $ERROR; then
247248
echo "Unknown command: '$CMD' (run 'pkg help' for usage information)"
248249
exit 1
249250
fi

0 commit comments

Comments
 (0)