diff options
Diffstat (limited to 'system/edit-config')
-rwxr-xr-x | system/edit-config | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/system/edit-config b/system/edit-config index 754f9374a..96ee82d4f 100755 --- a/system/edit-config +++ b/system/edit-config @@ -34,10 +34,20 @@ error() { } abspath() { - if [ -d "${1}" ]; then + if [ -d "${1}/" ]; then echo "$(cd "${1}" && /usr/bin/env PWD= pwd -P)/" - else + elif [ -f "${1}" ]; then echo "$(cd "$(dirname "${1}")" && /usr/bin/env PWD= pwd -P)/$(basename "${1}")" + elif echo "${1}" | grep -q '/'; then + if echo "${1}" | grep -q '^/'; then + mkdir -p "$(dirname "${1}")" + echo "$(cd "$(dirname "${1}")" && /usr/bin/env PWD= pwd -P)/$(basename "${1}")" + else + mkdir -p "${script_dir}/$(dirname "${1}")" + echo "${script_dir}/${1}" + fi + else + echo "${script_dir}/${1}" fi } @@ -153,7 +163,7 @@ list_files() { check_directories handle_container - if test -t; then + if test -t && command -v tput > /dev/null 2>&1; then width="$(tput cols)" fi |