Skip to content
This repository was archived by the owner on Jan 18, 2026. It is now read-only.

Commit c0ddc78

Browse files
author
Erazem Kokot
authored
Lint anarchy-chroot.sh (#881)
Update variable definitions in anarchy-chroot.sh
1 parent 48a21aa commit c0ddc78

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

lib/anarchy-chroot.sh

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,60 +28,60 @@ anarchy_chroot() {
2828
do
2929
echo -n "${Yellow}<${Red}root${Yellow}@${Green}${hostname}-chroot${Yellow}>: $working_dir>${Red}# ${ColorOff}" ; while IFS= read -r -n 1 -s char
3030
do
31-
if [ "$char" == $'\x1b' ]; then
31+
if [ "${char}" == $'\x1b' ]; then
3232
while IFS= read -r -n 2 -s rest
3333
do
34-
char+="$rest"
34+
char+="${rest}"
3535
break
3636
done
3737
fi
3838

39-
if [ "$char" == $'\x1b[D' ]; then
39+
if [ "${char}" == $'\x1b[D' ]; then
4040
pos=-1
41-
elif [ "$char" == $'\x1b[C' ]; then
41+
elif [ "${char}" == $'\x1b[C' ]; then
4242
pos=1
43-
elif [[ $char == $'\177' ]]; then
43+
elif [[ ${char} == $'\177' ]]; then
4444
input="${input%?}"
45-
echo -ne "\r\033[K${Yellow}<${Red}root${Yellow}@${Green}${hostname}-chroot${Yellow}>: $working_dir>${Red}# ${ColorOff}${input}"
45+
echo -ne "\r\033[K${Yellow}<${Red}root${Yellow}@${Green}${hostname}-chroot${Yellow}>: ${working_dir}>${Red}# ${ColorOff}${input}"
4646
## User input up
47-
elif [ "$char" == $'\x1b[A' ]; then
48-
if [ $histindex -gt 0 ]; then
47+
elif [ "${char}" == $'\x1b[A' ]; then
48+
if [ ${histindex} -gt 0 ]; then
4949
histindex+=-1
5050
input=$(echo -ne "${history[$histindex]}")
51-
echo -ne "\r\033[K${Yellow}<${Red}root${Yellow}@${Green}${hostname}-chroot${Yellow}>: $working_dir>${Red}# ${ColorOff}${history[$histindex]}"
51+
echo -ne "\r\033[K${Yellow}<${Red}root${Yellow}@${Green}${hostname}-chroot${Yellow}>: ${working_dir}>${Red}# ${ColorOff}${history[$histindex]}"
5252
fi
5353
## User input down
54-
elif [ "$char" == $'\x1b[B' ]; then
55-
if [ $histindex -lt $((${#history[@]} - 1)) ]; then
54+
elif [ "${char}" == $'\x1b[B' ]; then
55+
if [ ${histindex} -lt $((${#history[@]} - 1)) ]; then
5656
histindex+=1
5757
input=$(echo -ne "${history[$histindex]}")
58-
echo -ne "\r\033[K${Yellow}<${Red}root${Yellow}@${Green}${hostname}-chroot${Yellow}>: $working_dir>${Red}# ${ColorOff}${history[$histindex]}"
58+
echo -ne "\r\033[K${Yellow}<${Red}root${Yellow}@${Green}${hostname}-chroot${Yellow}>: ${working_dir}>${Red}# ${ColorOff}${history[$histindex]}"
5959
fi
6060
### Newline
61-
elif [ -z "$char" ]; then
61+
elif [ -z "${char}" ]; then
6262
echo
63-
history+=( "$input" )
63+
history+=( "${input}" )
6464
histindex=${#history[@]}
6565
break
6666
else
67-
echo -n "$char"
68-
input+="$char"
67+
echo -n "${char}"
68+
input+="${char}"
6969
fi
7070
done
7171

72-
if [ "$input" == "anarchy" ] || [ "$input" == "exit" ]; then
72+
if [ "${input}" == "anarchy" ] || [ "${input}" == "exit" ]; then
7373
rm /tmp/chroot_dir.var &> /dev/null
7474
clear
7575
break
76-
elif (<<<"$input" grep "^cd " &> /dev/null); then
77-
ch_dir=$(<<<$input cut -c4-)
78-
arch-chroot "$ARCH" /bin/bash -c "cd $working_dir ; cd $ch_dir ; pwd > /etc/chroot_dir.var"
79-
mv "$ARCH"/etc/chroot_dir.var /tmp/
76+
elif (<<<"${input}" grep "^cd " &> /dev/null); then
77+
ch_dir=$(<<<"${input}" cut -c4-)
78+
arch-chroot "${ARCH}" /bin/bash -c "cd ${working_dir} ; cd ${ch_dir} ; pwd > /etc/chroot_dir.var"
79+
mv "${ARCH}"/etc/chroot_dir.var /tmp/
8080
working_dir=$(</tmp/chroot_dir.var)
81-
elif (<<<"$input" grep "^help" &> /dev/null); then
82-
echo -e "$arch_chroot_msg"
81+
elif (<<<"${input}" grep "^help" &> /dev/null); then
82+
echo -e "${arch_chroot_msg}"
8383
else
84-
arch-chroot "$ARCH" /bin/bash -c "cd $working_dir ; $input"
84+
arch-chroot "${ARCH}" /bin/bash -c "cd ${working_dir} ; ${input}"
8585
fi
8686
input=
8787
done

0 commit comments

Comments
 (0)