Skip to content

Commit 945ea72

Browse files
authored
Use double brackets for integer comparisons
1 parent ee864e1 commit 945ea72

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

conty-start.sh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ script_version="1.27"
3131
# size to 0
3232
init_size=50000
3333
bash_size=1752808
34-
script_size=38502
34+
script_size=42559
3535
busybox_size=1181592
36-
utils_size=4392469
36+
utils_size=4393102
3737

3838
# Full path to the script
3939
if [ -n "${BASH_SOURCE[0]}" ]; then
@@ -75,7 +75,7 @@ else
7575
export working_dir="${BASE_DIR}"/"${conty_dir_name}"
7676
fi
7777

78-
if [ "${USE_SYS_UTILS}" != 1 ] && [ "${busybox_size}" -gt 0 ]; then
78+
if [ "${USE_SYS_UTILS}" != 1 ] && [[ "${busybox_size}" -gt 0 ]]; then
7979
busybox_bin_dir="${working_dir}"/busybox_bins
8080
busybox_path="${busybox_bin_dir}"/busybox
8181

@@ -402,7 +402,7 @@ nvidia_driver_handler () {
402402
curl -#Lo nvidia.run "${driver_url}"
403403

404404
# If the previous download failed, get the URL from FlatHub repo
405-
if [ ! -s nvidia.run ] || [ "$(stat -c%s nvidia.run)" -lt 30000000 ]; then
405+
if [ ! -s nvidia.run ] || [[ "$(stat -c%s nvidia.run)" -lt 30000000 ]]; then
406406
rm -f nvidia.run
407407
driver_url="https:$(curl -#Lo - "https://raw.githubusercontent.com/flathub/org.freedesktop.Platform.GL.nvidia/master/data/nvidia-${nvidia_driver_version}-x86_64.data" | cut -d ':' -f 6)"
408408
curl -#Lo nvidia.run "${driver_url}"
@@ -489,17 +489,17 @@ if [ "${dwarfs_image}" = 1 ]; then
489489
if getconf _PHYS_PAGES &>/dev/null && getconf PAGE_SIZE &>/dev/null; then
490490
memory_size="$(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / (1024 * 1024)))"
491491

492-
if [ "${memory_size}" -ge 45000 ]; then
492+
if [[ "${memory_size}" -ge 45000 ]]; then
493493
dwarfs_cache_size="4096M"
494-
elif [ "${memory_size}" -ge 23000 ]; then
494+
elif [[ "${memory_size}" -ge 23000 ]]; then
495495
dwarfs_cache_size="2048M"
496-
elif [ "${memory_size}" -ge 15000 ]; then
496+
elif [[ "${memory_size}" -ge 15000 ]]; then
497497
dwarfs_cache_size="1024M"
498-
elif [ "${memory_size}" -ge 7000 ]; then
498+
elif [[ "${memory_size}" -ge 7000 ]]; then
499499
dwarfs_cache_size="512M"
500-
elif [ "${memory_size}" -ge 3000 ]; then
500+
elif [[ "${memory_size}" -ge 3000 ]]; then
501501
dwarfs_cache_size="256M"
502-
elif [ "${memory_size}" -ge 1500 ]; then
502+
elif [[ "${memory_size}" -ge 1500 ]]; then
503503
dwarfs_cache_size="128M"
504504
else
505505
dwarfs_cache_size="64M"
@@ -509,7 +509,7 @@ if [ "${dwarfs_image}" = 1 ]; then
509509
if getconf _NPROCESSORS_ONLN &>/dev/null; then
510510
dwarfs_num_workers="$(getconf _NPROCESSORS_ONLN)"
511511

512-
if [ "${dwarfs_num_workers}" -ge 8 ]; then
512+
if [[ "${dwarfs_num_workers}" -ge 8 ]]; then
513513
dwarfs_num_workers=8
514514
fi
515515
fi
@@ -518,7 +518,7 @@ fi
518518
# Extract utils.tar.gz
519519
mkdir -p "${working_dir}"
520520

521-
if ([ "${USE_SYS_UTILS}" != 1 ] && [ "${utils_size}" -gt 0 ]) || [ "$1" = "-u" ]; then
521+
if ([ "${USE_SYS_UTILS}" != 1 ] && [[ "${utils_size}" -gt 0 ]]) || [ "$1" = "-u" ]; then
522522
# Check if filesystem of the working_dir is mounted without noexec
523523
if ! exec_test; then
524524
if [ -z "${BASE_DIR}" ]; then
@@ -701,7 +701,7 @@ run_bwrap () {
701701
sandbox_params+=(--dir "${HOME}")
702702
fi
703703

704-
if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 2 ]; then
704+
if [ -n "${SANDBOX_LEVEL}" ] && [[ "${SANDBOX_LEVEL}" -ge 2 ]]; then
705705
sandbox_level_msg="(level 2)"
706706
sandbox_params+=(--dir "${XDG_RUNTIME_DIR}" \
707707
--ro-bind-try "${XDG_RUNTIME_DIR}"/"${wayland_socket}" "${XDG_RUNTIME_DIR}"/"${wayland_socket}" \
@@ -716,7 +716,7 @@ run_bwrap () {
716716
--bind-try /run/dbus /run/dbus)
717717
fi
718718

719-
if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 3 ]; then
719+
if [ -n "${SANDBOX_LEVEL}" ] && [[ "${SANDBOX_LEVEL}" -ge 3 ]]; then
720720
sandbox_level_msg="(level 3)"
721721
DISABLE_NET=1
722722
fi
@@ -759,7 +759,7 @@ run_bwrap () {
759759

760760
if [ "${DISABLE_X11}" != 1 ]; then
761761
if [ "$(ls /tmp/.X11-unix 2>/dev/null)" ]; then
762-
if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 3 ]; then
762+
if [ -n "${SANDBOX_LEVEL}" ] && [[ "${SANDBOX_LEVEL}" -ge 3 ]]; then
763763
xsockets+=(--ro-bind-try /tmp/.X11-unix/X"${xephyr_display}" /tmp/.X11-unix/X"${xephyr_display}" \
764764
--setenv "DISPLAY" :"${xephyr_display}")
765765
else
@@ -782,7 +782,7 @@ run_bwrap () {
782782
mount_opt=(--bind-try /opt /opt)
783783
fi
784784

785-
if ([ "${NVIDIA_HANDLER}" -ge 1 ] || [ "${USE_OVERLAYFS}" = 1 ]) && \
785+
if ([[ "${NVIDIA_HANDLER}" -ge 1 ]] || [ "${USE_OVERLAYFS}" = 1 ]) && \
786786
[ "$(ls "${overlayfs_dir}"/merged 2>/dev/null)" ]; then
787787
newroot_path="${overlayfs_dir}"/merged
788788
else
@@ -1038,7 +1038,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || launch_wrapper "${mount_command[@
10381038
available_disk_space="$(df -P -B1 "${PWD}" | awk 'END {print $4}')"
10391039
required_disk_space="$((current_file_size*7))"
10401040

1041-
if [ "${available_disk_space}" -lt "${required_disk_space}" ]; then
1041+
if [[ "${available_disk_space}" -lt "${required_disk_space}" ]]; then
10421042
echo "Not enough free disk space"
10431043
echo "You need at least $((required_disk_space/1024/1024)) MB of free space"
10441044
exit 1
@@ -1084,7 +1084,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || launch_wrapper "${mount_command[@
10841084
echo "Creating an image..."
10851085
launch_wrapper "${compression_command[@]}"
10861086

1087-
if [ "${init_size}" -gt 0 ]; then
1087+
if [[ "${init_size}" -gt 0 ]]; then
10881088
tail -c +$((init_size+bash_size+1)) "${script}" | head -c "${script_size}" > conty-start.sh
10891089
else
10901090
head -c "${script_size}" "${script}" > conty-start.sh
@@ -1126,7 +1126,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || launch_wrapper "${mount_command[@
11261126
exit
11271127
fi
11281128

1129-
if [ "${NVIDIA_HANDLER}" -ge 1 ]; then
1129+
if [[ "${NVIDIA_HANDLER}" -ge 1 ]]; then
11301130
if [ -f /sys/module/nvidia/version ]; then
11311131
unset NVIDIA_SHARED
11321132

@@ -1294,7 +1294,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || launch_wrapper "${mount_command[@
12941294
fi
12951295

12961296
# If SANDBOX_LEVEL is 3, run Xephyr and openbox before running applications
1297-
if [ "${SANDBOX}" = 1 ] && [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 3 ]; then
1297+
if [ "${SANDBOX}" = 1 ] && [ -n "${SANDBOX_LEVEL}" ] && [[ "${SANDBOX_LEVEL}" -ge 3 ]]; then
12981298
if [ -f "${mount_point}"/usr/bin/Xephyr ]; then
12991299
if [ -z "${XEPHYR_SIZE}" ]; then
13001300
XEPHYR_SIZE="800x600"

0 commit comments

Comments
 (0)