dirname and basename in pure bash

This commit is contained in:
olli 2023-11-27 10:32:16 +01:00
parent 0b2da67759
commit 2942adc0c8
2 changed files with 10 additions and 0 deletions

5
gaboshlib/g_basename.sh Normal file
View File

@ -0,0 +1,5 @@
function g_basename {
g_basename_result="${1##*/}"
g_basename_result="${g_basename_result:-/}"
}

5
gaboshlib/g_dirname.sh Normal file
View File

@ -0,0 +1,5 @@
function g_dirname {
g_dirname_result="${1%"${1##*[!/]}"}"
g_dirname_result="${g_dirname_result%/*}"
g_dirname_result=${g_dirname_result:-/}
}