@@ -66,35 +66,25 @@ notices+=( "$(colorize white "*" ) $( colorize orange "${selected}" ) is mounted
66
66
67
67
# Track submounts so we know how to clean up on exit
68
68
trap cleanup HUP INT QUIT ABRT EXIT
69
- _mnt=( " ${mountpoint} " )
70
69
71
70
zdebug " mounted ${selected} to ${mountpoint} "
72
71
73
- mount -B /tmp " ${mountpoint} /tmp" \
74
- && _mnt=( " ${mountpoint} /tmp" " ${_mnt[@]} " )
75
-
76
- mount -t proc proc " ${mountpoint} /proc" \
77
- && _mnt=( " ${mountpoint} /proc" " ${_mnt[@]} " )
78
-
79
- mount -t sysfs sys " ${mountpoint} /sys" \
80
- && _mnt=( " ${mountpoint} /sys" " ${_mnt[@]} " )
81
-
82
- mount -B /dev " ${mountpoint} /dev" \
83
- && _mnt=( " ${mountpoint} /dev" " ${_mnt[@]} " )
72
+ mount -B /tmp " ${mountpoint} /tmp"
73
+ mount -t proc proc " ${mountpoint} /proc"
74
+ mount -t sysfs sys " ${mountpoint} /sys"
75
+ mount -B /dev " ${mountpoint} /dev"
84
76
85
77
86
78
if mount_efivarfs " ${efivarmode} " ; then
87
79
efivarfs=" ${mountpoint} /sys/firmware/efi/efivars"
88
- mount_efivarfs " ${efivarmode} " " ${efivarfs} " \
89
- && _mnt=( " ${efivarfs} " " ${_mnt[@]} " )
80
+ mount_efivarfs " ${efivarmode} " " ${efivarfs} "
90
81
91
82
notices+=( " \n$( colorize white " *" ) $( colorize orange " efivarfs" ) is mounted ${writemode} " )
92
83
fi
93
84
94
85
# Not all /dev filesystems have /dev/pts
95
86
[ -d " ${mountpoint} /dev/pts" ] \
96
- && mount -t devpts pts " ${mountpoint} /dev/pts" \
97
- && _mnt=( " ${mountpoint} /dev/pts" " ${_mnt[@]} " )
87
+ && mount -t devpts pts " ${mountpoint} /dev/pts"
98
88
99
89
_SHELL=
100
90
if [ -x " ${mountpoint} /bin/bash" ] \
@@ -126,3 +116,20 @@ unset PROMPT_COMMAND
126
116
if ! env " PS1=\[\033[0;33m\]${selected} \[\033[0m\] \w > " chroot ${mountpoint} ${_SHELL} ${chroot_extra} ; then
127
117
zdebug " chroot ${selected} :${_SHELL} returned code $? "
128
118
fi
119
+
120
+ mounts=()
121
+
122
+ mp_re=" ^${mountpoint} "
123
+
124
+ # shellcheck disable=SC2034
125
+ while read -r skip mp skip skip ; do
126
+ if [[ " ${mp} " =~ ${mp_re} ]]; then
127
+ lines=" ${mp// [!\/]/ } "
128
+ lines=" ${# lines} "
129
+ mounts+=( " ${lines} ,${mp} " )
130
+ fi
131
+ done < /proc/self/mounts
132
+
133
+ while IFS=$' \n ' read -r filesystem; do
134
+ _mnt+=( " ${filesystem#* ,} " )
135
+ done <<< " $( printf '%s\n' " ${mounts[@]} " | sort -n -k1 -r )"
0 commit comments