Fix two issues with the edit-config script. (#14545)
Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
Austin S. Hemmelgarn committed
Feb 21, 2023 at 05:45 UTC
faf2c718f033297898f4bc24addfcfb9cddd77bc
1 file changed
+12
-2
system/edit-config
+12
-2
@@ -34,10 +34,20 @@ error() {
34
}
35
36
abspath() {
37
- if [ -d "${1}" ]; then
37
+ if [ -d "${1}/" ]; then
38
echo "$(cd "${1}" && /usr/bin/env PWD= pwd -P)/"
39
- else
39
+ elif [ -f "${1}" ]; then
40
echo "$(cd "$(dirname "${1}")" && /usr/bin/env PWD= pwd -P)/$(basename "${1}")"
41
+ elif echo "${1}" | grep -q '/'; then
42
+ if echo "${1}" | grep -q '^/'; then
43
+ mkdir -p "$(dirname "${1}")"
44
+ echo "$(cd "$(dirname "${1}")" && /usr/bin/env PWD= pwd -P)/$(basename "${1}")"
45
+ else
46
+ mkdir -p "${script_dir}/$(dirname "${1}")"
47
+ echo "${script_dir}/${1}"
48
+ fi
49
+ else
50
+ echo "${script_dir}/${1}"
51
fi
52
}
53