Try to troubleshoot directory parsing bugs

This commit is contained in:
Davide Depau 2019-09-09 00:42:35 +02:00
parent 25e30752b4
commit 3272a55682
Signed by: depau
GPG key ID: C7D999B6A55EFE86

21
shcrt
View file

@ -45,6 +45,11 @@ function copy_to_clipboard {
fi
}
# Escape bash variables
function no_dollars {
sed 's/\$/\\$/g'
}
function scrt_session_path {
if is_wsl; then
appdata="$(wsl_win_var '%APPDATA%' | win_path_to_wsl)"
@ -136,7 +141,7 @@ function scrt_search {
return 1
fi
results="$(scrt_find "$query")"
results="$(scrt_find "$query" | no_dollars)"
if [[ "$results" == "" ]]; then
alert_message "No results"
@ -164,16 +169,16 @@ function scrt_search {
function scrt_menu {
listing="$(scrt_ls)"
menu_listing="$(echo "$listing" | cut -d "\\" -f 1)"
menu_listing="$(echo "$listing" | cut -d "\\" -f 1 | no_dollars)"
now_at="$(echo "$current_path" | sed -e 's|^[.]|/|' -e 's|//|/|')"
now_at="$(echo "$current_path" | sed -e 's|^[.]|/|' -e 's|//|/|' | no_dollars)"
IFSBAK="$IFS"
IFS=$'\n'
if [[ "$current_path" != "" ]] && [[ "$current_path" != "." ]]; then
menu "$now_at_entry $now_at" "$search_entry" "$up_entry" $menu_listing
menu "$now_at_entry $now_at" "$search_entry" "$up_entry" "$menu_listing"
else
menu "$now_at_entry $now_at" "$search_entry" $menu_listing
menu "$now_at_entry $now_at" "$search_entry" "$menu_listing"
fi
IFS="$IFSBAK"
@ -181,6 +186,12 @@ function scrt_menu {
choice="$(echo "$listing" | grep "$menu_choice" | cut -d "\\" -f 2)"
choice_path="$(scrt_pwd)/$choice"
echo "HERE MENU"
echo "'$menu_choice' '$up_entry' '$search_entry'"
echo "'$choice'"
echo "'$choice_path'"
read
if [[ "$menu_choice" == "" ]] || [[ "$menu_choice" == "$up_entry" ]]; then
scrt_cd ..
if [[ "$current_path" == "" ]] || [[ "$current_path" == ".." ]]; then