Skip to content

Commit 4d735f8

Browse files
committed
update
1 parent c96e281 commit 4d735f8

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

funcs.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@ abs_path(){
296296
fi
297297
}
298298

299+
r_trim(){
300+
# ^ char in $2 not supported (needs extra care).
301+
echo "$1" |sed "s=[$2]*$=="
302+
}
303+
304+
sanit_path(){
305+
echo "$1" |sed -e 's=//*=/=g' -e 's=/$=='
306+
}
307+
299308
fstab_path(){
300309
local path=$1
301310
local s=
@@ -326,7 +335,7 @@ insert_fsentry_fstab(){
326335
}
327336

328337
remove_fsentry_fstab(){
329-
local edit=$1
338+
local edit="$1"
330339
if [ "$edit" != "" ]; then
331340
proc="proc $(fstab_path "${edit}proc") proc defaults 0 0"
332341
sys="sysfs $(fstab_path "${edit}sys") sysfs defaults 0 0"
@@ -346,6 +355,7 @@ remove_fsentry_fstab(){
346355
}
347356

348357
mount_fs(){
358+
edit=$(sanit_path "$edit")/ #must have / at end
349359
if [ "$edit" != "" ]; then
350360
insert_fsentry_fstab
351361
mount devtmpfs "${edit}"dev -t devtmpfs && msg_out 'mounted dev'
@@ -359,7 +369,12 @@ mount_fs(){
359369

360370
umount_fs(){
361371
livedir=$(cat "$JLIVEdirF")
362-
edit=${livedir+$livedir/}edit/
372+
if [ "$livedir" = "" ]; then
373+
edit=edit/
374+
else
375+
edit="$livedir/edit/"
376+
fi
377+
edit=$(sanit_path "$edit")/ #must have / at end
363378
if mount |awk '{print $3}' |grep -qF "${edit}"proc; then
364379
if umount "${edit}"proc || umount -lf "${edit}"proc ; then
365380
msg_out "unmount proc success"
@@ -550,12 +565,11 @@ jlcd_start(){
550565
err_out "directory doesn't exist: $livedir"
551566
fi
552567
done
568+
livedir=$(sanit_path "$livedir")
553569
liveconfigfile="$livedir/.config"
554570
touch "$liveconfigfile"
555571
chmod 777 "$liveconfigfile"
556572
edit=$(abs_path "$livedir/edit")/ #must end with a slash
557-
#we got a valid $edit now
558-
insert_fsentry_fstab
559573

560574
set -a
561575
if [ -f "$livedir/$JL_sconf" ]; then

0 commit comments

Comments
 (0)