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