Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 73ebc9d

Browse files
authored
Util function fix (CI Ignore)
1 parent 6ae40d5 commit 73ebc9d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

script-library/shared/utils.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
# If in automatic mode, determine if a user already exists, if not use vscode
1+
# If in automatic mode, determine if a user already exists, if not use root
22
detect_user() {
33
local user_variable_name=${1:-username}
4-
local user_variable_value=${!user_variable_name}
54
local possible_users=${2:-("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")}
6-
if [ "${user_variable_value}" = "auto" ] || [ "${user_variable_value}" = "automatic" ]; then
7-
declare -g ${user_variable_name}=vscode
5+
if [ "${!user_variable_name}" = "auto" ] || [ "${!user_variable_name}" = "automatic" ]; then
6+
declare -g ${user_variable_name}=""
87
for current_user in ${possible_users[@]}; do
9-
if id -u ${current_user} > /dev/null 2>&1; then
10-
declare -g ${user_variable_name}=${current_user}
8+
if id -u "${current_user}" > /dev/null 2>&1; then
9+
declare -g ${user_variable_name}="${current_user}"
1110
break
1211
fi
1312
done
14-
elif [ "${user_variable_value}" = "none" ] || ! id "${user_variable_value}" > /dev/null 2>&1; then
13+
fi
14+
if [ "${!user_variable_name}" = "" ] || [ "${!user_variable_name}" = "none" ] || ! id -u "${!user_variable_name}" > /dev/null 2>&1; then
1515
declare -g ${user_variable_name}=root
1616
fi
1717
}
18+
1819
# Use Oryx to install something using a partial version match
1920
oryx_install() {
2021
local platform=$1
@@ -240,4 +241,4 @@ apt_cache_version_soft_match() {
240241
# Use this value as the return value of this function
241242
declare -g ${variable_name}="=${fuzzy_version}"
242243
echo "${variable_name}=${!variable_name}"
243-
}
244+
}

0 commit comments

Comments
 (0)