On 08/08/13 04:42, lolilolicon wrote:
+ # pacman 4.1 to 4.2 upgrade - remove directory symlink support
+ dirlist=() + + unset GREP_OPTIONS + while IFS= read -r dir; do + dirlist+=("/${dir%/}") + done < <(grep -h '/$' "$dbroot"/local/*/files | sort -u) + + mapfile -t dirlist < <(find "${dirlist[@]}" -maxdepth 0 -type l) + + if [[ ${#dirlist[@]} != 0 ]]; then + msg "$(gettext "Pre-4.2 database format detected - upgrading...")" + for dir in ${dirlist[@]}; do missing quote, "${dirlist[@]}"
+ realdir=( $(cd $dir; pwd -P) ) missing quote, "$dir"; why is realdir an array?
+ sed -i "s#^${dir#/}/#${realdir#/}/#" "$dbroot"/local/*/files If it's almost safe to assume paths don't include '\n', it's far less so to assume they don't include '#'. Also $dir is treated as a pattern, not a fixed string here. This should be better:
awk -v "dir=${dir#/}/" -v "realdir=${realdir#/}/" ' BEGIN { i = length(dir) + 1 } { if (index($0, dir) == 1) { printf("%s%s\n", realdir, substr($0, i)) } else { print } }'
awk doesn't have the convenience of in place file editting though, so we may have to wrap this inside a loop, and store the updated data in a temp file (or just a var?)...
@Dave: comments here? I believe I got the sed from you - although I am sure it was supposed to be a quick and dirty hack... Allan