Skip to content

Commit

Permalink
* fix r_extensionless_filename
Browse files Browse the repository at this point in the history
* add --silent-but-warn flag as a MULLE_FLAG_LOG_TERSE option
* add shell_is_builtin_command function
  • Loading branch information
mulle-nat committed Oct 18, 2023
1 parent 2316a96 commit 4b00ae9
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 51 deletions.
2 changes: 1 addition & 1 deletion mulle-bash
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fi
# this is "our" version
# the actual loaded version may differ (and will change this variable)
#
MULLE_BASHFUNCTIONS_VERSION="6.0.0"
MULLE_BASHFUNCTIONS_VERSION="6.1.0"
MULLE_BASHFUNCTIONS_LIBEXEC_DIRNAME="libexec"
MULLE_EXECUTABLE="$1"

Expand Down
49 changes: 37 additions & 12 deletions src/mulle-bashfunctions-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,23 @@ function shell_is_function()
}


function shell_is_builtin_command()
{
if [ ${ZSH_VERSION+x} ]
then
case "`LC_C=C whence -w "$1" `" in
*:*builtin)
return 0
;;
esac
return 1
fi

[ "`type -t "$1"`" = "builtin" ]
return $?
}


function r_shell_indirect_expand()
{
local key="$1"
Expand Down Expand Up @@ -621,7 +638,7 @@ _log_warning()

_log_info()
{
if [ "${MULLE_FLAG_LOG_TERSE:-}" != 'YES' ]
if ! [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' -o "${MULLE_FLAG_LOG_TERSE:-}" = 'WARN' ]
then
_log_printf "${C_INFO}%b${C_RESET}\n" "$*"
fi
Expand Down Expand Up @@ -786,9 +803,13 @@ log_set_trace_level()
alias log_verbose=': #'
fi

if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' ]
if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' -o "${MULLE_FLAG_LOG_TERSE:-}" = 'WARN' ]
then
alias log_info=': #'
fi

if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' ]
then
alias log_warning=': #'
fi
:
Expand Down Expand Up @@ -2513,6 +2534,10 @@ function options_technical_flags()
MULLE_FLAG_LOG_TERSE='YES'
;;

--silent-but-warn)
MULLE_FLAG_LOG_TERSE='WARN'
;;

-v|--verbose)
after_trace_warning "${flag}"

Expand Down Expand Up @@ -2977,7 +3002,7 @@ function r_extensionless_basename()

function r_extensionless_filename()
{
RVAL="${RVAL%.*}"
RVAL="${1%.*}"
}


Expand Down Expand Up @@ -3719,6 +3744,15 @@ _r_make_tmp_in_dir_uuidgen()
fi

RVAL="${tmpdir}/${name}-${uuid}${extension}"
if [ -e "${RVAL}" ]
then
fluke=$((fluke + 1 ))
if [ "${fluke}" -gt 20 ]
then
fail "Could not create \"${RVAL}\" (${filetype:-f})"
fi
continue
fi

case "${filetype}" in
*d*)
Expand All @@ -3729,15 +3763,6 @@ _r_make_tmp_in_dir_uuidgen()
exekutor "${TOUCH}" "${RVAL}" 2> /dev/null && return 0
;;
esac

if [ ! -e "${RVAL}" ]
then
fluke=$((fluke + 1 ))
if [ "${fluke}" -gt 20 ]
then
fail "Could not (even repeatedly) create \"${RVAL}\" (${filetype:-f})"
fi
fi
done
}

Expand Down
49 changes: 37 additions & 12 deletions src/mulle-bashfunctions-embed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,23 @@ function shell_is_function()
}


function shell_is_builtin_command()
{
if [ ${ZSH_VERSION+x} ]
then
case "`LC_C=C whence -w "$1" `" in
*:*builtin)
return 0
;;
esac
return 1
fi

[ "`type -t "$1"`" = "builtin" ]
return $?
}


function r_shell_indirect_expand()
{
local key="$1"
Expand Down Expand Up @@ -439,7 +456,7 @@ _log_warning()

_log_info()
{
if [ "${MULLE_FLAG_LOG_TERSE:-}" != 'YES' ]
if ! [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' -o "${MULLE_FLAG_LOG_TERSE:-}" = 'WARN' ]
then
_log_printf "${C_INFO}%b${C_RESET}\n" "$*"
fi
Expand Down Expand Up @@ -604,9 +621,13 @@ log_set_trace_level()
alias log_verbose=': #'
fi

if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' ]
if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' -o "${MULLE_FLAG_LOG_TERSE:-}" = 'WARN' ]
then
alias log_info=': #'
fi

if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' ]
then
alias log_warning=': #'
fi
:
Expand Down Expand Up @@ -2331,6 +2352,10 @@ function options_technical_flags()
MULLE_FLAG_LOG_TERSE='YES'
;;

--silent-but-warn)
MULLE_FLAG_LOG_TERSE='WARN'
;;

-v|--verbose)
after_trace_warning "${flag}"

Expand Down Expand Up @@ -2795,7 +2820,7 @@ function r_extensionless_basename()

function r_extensionless_filename()
{
RVAL="${RVAL%.*}"
RVAL="${1%.*}"
}


Expand Down Expand Up @@ -3537,6 +3562,15 @@ _r_make_tmp_in_dir_uuidgen()
fi

RVAL="${tmpdir}/${name}-${uuid}${extension}"
if [ -e "${RVAL}" ]
then
fluke=$((fluke + 1 ))
if [ "${fluke}" -gt 20 ]
then
fail "Could not create \"${RVAL}\" (${filetype:-f})"
fi
continue
fi

case "${filetype}" in
*d*)
Expand All @@ -3547,15 +3581,6 @@ _r_make_tmp_in_dir_uuidgen()
exekutor "${TOUCH}" "${RVAL}" 2> /dev/null && return 0
;;
esac

if [ ! -e "${RVAL}" ]
then
fluke=$((fluke + 1 ))
if [ "${fluke}" -gt 20 ]
then
fail "Could not (even repeatedly) create \"${RVAL}\" (${filetype:-f})"
fi
fi
done
}

Expand Down
29 changes: 27 additions & 2 deletions src/mulle-bashfunctions-minimal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,23 @@ function shell_is_function()
}


function shell_is_builtin_command()
{
if [ ${ZSH_VERSION+x} ]
then
case "`LC_C=C whence -w "$1" `" in
*:*builtin)
return 0
;;
esac
return 1
fi

[ "`type -t "$1"`" = "builtin" ]
return $?
}


function r_shell_indirect_expand()
{
local key="$1"
Expand Down Expand Up @@ -621,7 +638,7 @@ _log_warning()

_log_info()
{
if [ "${MULLE_FLAG_LOG_TERSE:-}" != 'YES' ]
if ! [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' -o "${MULLE_FLAG_LOG_TERSE:-}" = 'WARN' ]
then
_log_printf "${C_INFO}%b${C_RESET}\n" "$*"
fi
Expand Down Expand Up @@ -786,9 +803,13 @@ log_set_trace_level()
alias log_verbose=': #'
fi

if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' ]
if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' -o "${MULLE_FLAG_LOG_TERSE:-}" = 'WARN' ]
then
alias log_info=': #'
fi

if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' ]
then
alias log_warning=': #'
fi
:
Expand Down Expand Up @@ -2513,6 +2534,10 @@ function options_technical_flags()
MULLE_FLAG_LOG_TERSE='YES'
;;

--silent-but-warn)
MULLE_FLAG_LOG_TERSE='WARN'
;;

-v|--verbose)
after_trace_warning "${flag}"

Expand Down
17 changes: 17 additions & 0 deletions src/mulle-bashfunctions-none.sh
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,23 @@ function shell_is_function()
}


function shell_is_builtin_command()
{
if [ ${ZSH_VERSION+x} ]
then
case "`LC_C=C whence -w "$1" `" in
*:*builtin)
return 0
;;
esac
return 1
fi

[ "`type -t "$1"`" = "builtin" ]
return $?
}


function r_shell_indirect_expand()
{
local key="$1"
Expand Down
49 changes: 37 additions & 12 deletions src/mulle-bashfunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,23 @@ function shell_is_function()
}


function shell_is_builtin_command()
{
if [ ${ZSH_VERSION+x} ]
then
case "`LC_C=C whence -w "$1" `" in
*:*builtin)
return 0
;;
esac
return 1
fi

[ "`type -t "$1"`" = "builtin" ]
return $?
}


function r_shell_indirect_expand()
{
local key="$1"
Expand Down Expand Up @@ -621,7 +638,7 @@ _log_warning()

_log_info()
{
if [ "${MULLE_FLAG_LOG_TERSE:-}" != 'YES' ]
if ! [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' -o "${MULLE_FLAG_LOG_TERSE:-}" = 'WARN' ]
then
_log_printf "${C_INFO}%b${C_RESET}\n" "$*"
fi
Expand Down Expand Up @@ -786,9 +803,13 @@ log_set_trace_level()
alias log_verbose=': #'
fi

if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' ]
if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' -o "${MULLE_FLAG_LOG_TERSE:-}" = 'WARN' ]
then
alias log_info=': #'
fi

if [ "${MULLE_FLAG_LOG_TERSE:-}" = 'YES' ]
then
alias log_warning=': #'
fi
:
Expand Down Expand Up @@ -2513,6 +2534,10 @@ function options_technical_flags()
MULLE_FLAG_LOG_TERSE='YES'
;;

--silent-but-warn)
MULLE_FLAG_LOG_TERSE='WARN'
;;

-v|--verbose)
after_trace_warning "${flag}"

Expand Down Expand Up @@ -2977,7 +3002,7 @@ function r_extensionless_basename()

function r_extensionless_filename()
{
RVAL="${RVAL%.*}"
RVAL="${1%.*}"
}


Expand Down Expand Up @@ -3719,6 +3744,15 @@ _r_make_tmp_in_dir_uuidgen()
fi

RVAL="${tmpdir}/${name}-${uuid}${extension}"
if [ -e "${RVAL}" ]
then
fluke=$((fluke + 1 ))
if [ "${fluke}" -gt 20 ]
then
fail "Could not create \"${RVAL}\" (${filetype:-f})"
fi
continue
fi

case "${filetype}" in
*d*)
Expand All @@ -3729,15 +3763,6 @@ _r_make_tmp_in_dir_uuidgen()
exekutor "${TOUCH}" "${RVAL}" 2> /dev/null && return 0
;;
esac

if [ ! -e "${RVAL}" ]
then
fluke=$((fluke + 1 ))
if [ "${fluke}" -gt 20 ]
then
fail "Could not (even repeatedly) create \"${RVAL}\" (${filetype:-f})"
fi
fi
done
}

Expand Down
Loading

0 comments on commit 4b00ae9

Please sign in to comment.