If path is a symlink, display the target

This commit is contained in:
Jeremy Gardais 2019-10-09 18:10:46 +02:00
parent 1ca4ded439
commit 9706ecaa25
1 changed files with 12 additions and 8 deletions

View File

@ -50,6 +50,7 @@ steam_userdata_games="760 35700 35720 55230 204360 206420 218820 247080 255870 3
### To be able to manage white space in directory name, the field separator is %.
### eg. GAME NAME/data.save%other game/*.sav
### 620 Portal 2 https://pcgamingwiki.com/wiki/Portal_2 (solo only, multiplayer is on Steam cloud)
### 251470 TowerFall Ascension https://pcgamingwiki.com/wiki/TowerFall_Ascension (not managed cause no substree, check $XDG_DATA_HOME)
### 274190 Broforce https://pcgamingwiki.com/wiki/Broforce
steam_common_games_pattern="Portal 2/*.sav%Broforce/*.sav"
# }}}
@ -158,12 +159,13 @@ done
# Manage Steam userdata save game {{{
for game_id in ${steam_userdata_games}; do
local_game_path="${HOME}/${steam_userdata}/${game_id}"
local_game_path_type="$(file ${local_game_path} | cut -d' ' -f2)"
local_game_path_type="$(file "${local_game_path}" | cut -d' ' -f2)"
case ${local_game_path_type} in
## Data is already a symlink
"symbolic")
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam userdata for loop — The data of ${game_id} are already symlinked to .... Skip."
link_name="$(file "${local_game_path}" | sed 's;.* symbolic link to \(.*\);\1;')"
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam userdata for loop — The data of ${game_id} are already symlinked to ${link_name} . Skip."
;;
## Data is still a directory
"directory")
@ -187,8 +189,8 @@ done
IFS="%"
for game_pattern in ${steam_common_games_pattern}; do
## Separate the game_name and the directory|file to backup|symlink
game_name="$(echo ${game_pattern} | cut -d"/" -f1)"
save_pattern="$(echo ${game_pattern} | cut -d"/" -f2)"
game_name="$(echo "${game_pattern}" | cut -d"/" -f1)"
save_pattern="$(echo "${game_pattern}" | cut -d"/" -f2)"
## If the game is installed
if [ -d "${HOME}/${steam_common}/${game_name}" ]; then
@ -214,7 +216,8 @@ for game_pattern in ${steam_common_games_pattern}; do
case ${local_save_path_type} in
## Data is already a symlink
"symbolic"|"symboliclink"|"l")
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam common for loop — The data of ${game_name} are already symlinked to .... Skip."
link_name="$(file "${local_save_path}" | sed 's;.* symbolic link to \(.*\);\1;')"
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam common for loop — The data of ${game_name} are already symlinked to ${link_name} . Skip."
;;
## Data is still a directory, try to move it
"directory"|"d")
@ -240,8 +243,8 @@ done
# Manage Steam compatdata save game {{{
for game_pattern in ${steam_compatdata_games_pattern}; do
## Separate the game_id and the directory|file to backup|symlink
game_id="$(echo ${game_pattern} | cut -d"/" -f1)"
save_pattern="$(echo ${game_pattern} | cut -d"/" -f2)"
game_id="$(echo "${game_pattern}" | cut -d"/" -f1)"
save_pattern="$(echo "${game_pattern}" | cut -d"/" -f2)"
## If the game is installed
if [ -d "${HOME}/${steam_compatdata}/${game_id}" ]; then
@ -267,7 +270,8 @@ for game_pattern in ${steam_compatdata_games_pattern}; do
case ${local_save_path_type} in
## Data is already a symlink
"symbolic"|"symboliclink"|"l")
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam compatdata for loop — The data of ${game_id} are already symlinked to .... Skip."
link_name="$(file "${local_save_path}" | sed 's;.* symbolic link to \(.*\);\1;')"
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam compatdata for loop — The data of ${game_id} are already symlinked to ${link_name} . Skip."
;;
## Data is still a directory, try to move it
"directory"|"d")