Skip to content
Nat! edited this page Apr 7, 2025 · 5 revisions

Figure out if the script is sourced or executed

Assuming your script is called "config.sh":

if [ "${MULLE_EXECUTABLE##*/}" = "config.sh" ]
then
   printf "executed\n"
fi

Dump all values set by mulle-bashfunctions:

#! /usr/bin/env mulle-bash

all_vars()
{
   (set -o posix ; set | sort)
}

all_envs=`printenv`

.foreachline variable in `all_vars`
.do
    key="${variable%%=*}"
    r_escaped_grep_pattern "${key}"
    if grep -E -q "^${RVAL}=" <<< "${all_envs}"
    then
       .continue
    fi    
    case "${key}" in 
       C_*|MULLE_*)
          printf "%s\n" "${variable}"
       ;;
    esac
.done
Clone this wiki locally