Skip to content
Browse files

fix trace_filter

  • Loading branch information...
1 parent 447d8a3 commit e4e731159c115636776976edbbf7f48c054da4f5 @mpapis mpapis committed
View
2 core/api/shell/array/functions
@@ -28,7 +28,7 @@
array()
{
- trace_filter array
+ trace_filter array || set -o xtrace
local _command _subcommand _name _variable
_command="$1"
shift || __sm.log.fail "Array command must be given as the first parameter."
View
2 core/api/shell/command/functions
@@ -2,7 +2,7 @@
command()
{
- trace_filter command
+ trace_filter command || set -o xtrace
local _command _subcommand _token _user _code _flags
_flags=()
View
2 core/api/shell/config/functions
@@ -3,7 +3,7 @@
config()
{
- trace_filter config
+ trace_filter config || set -o xtrace
local _token _command _file _key _value _variable _prefix
while (( $# ))
View
2 core/api/shell/extensions/functions
@@ -7,7 +7,7 @@ api_extensions_initialize()
extension()
{
- trace_filter extensions
+ trace_filter extensions || set -o xtrace
local _command _params _name _uri __extension_commands
_params=()
View
2 core/api/shell/files/functions
@@ -13,7 +13,7 @@ file() { files "$@" ; }
files()
{
- trace_filter filesystem
+ trace_filter filesystem || set -o xtrace
local _token _command _subcommand _path _file _files _source _target _mode \
_owner _flags _string _regex __files_commands
View
2 core/api/shell/os/functions
@@ -11,7 +11,7 @@
#
os()
{
- trace_filter os
+ trace_filter os || set -o xtrace
local _command _subcommand
View
2 core/api/shell/package/functions
@@ -39,7 +39,7 @@
#
package()
{
- trace_filter package
+ trace_filter package || set -o xtrace
local _token _subcommand _command _logfile _lines _params
_lines=50
_params=()
View
2 core/api/shell/paths/functions
@@ -48,7 +48,7 @@ path() { paths "$@" ; }
paths()
{
- trace_filter filesystem
+ trace_filter filesystem || set -o xtrace
local _token _command _path _paths _source _target _mode _owner _flags _glob __paths_commands
_paths=()
__paths_commands=(
View
2 core/api/shell/service/functions
@@ -9,7 +9,7 @@
# This is what is used by service extensions.
service()
{
- trace_filter service
+ trace_filter service || set -o xtrace
local _token _command _parameters
_parameters=()
View
2 core/api/shell/templates/functions
@@ -21,7 +21,7 @@
template() { templates "$@" ; }
templates()
{
- trace_filter templates
+ trace_filter templates || set -o xtrace
local _command _name _target _source _mode _owner _template _params __templates_commands
_source="${extension_templates_path}" \
View
2 core/api/shell/time/functions
@@ -2,7 +2,7 @@
timestamp()
{
- trace_filter timestamp
+ trace_filter timestamp || set -o xtrace
local _command _params=() _name _uri __extension_commands
_params=()
View
2 core/api/shell/user/functions
@@ -2,7 +2,7 @@
user()
{
- trace_filter users
+ trace_filter users || set -o xtrace
local _command _subcommand _user _group _source _flags _value _shell __user_commands
_flags=()
View
2 core/api/shell/variables/functions
@@ -4,7 +4,7 @@ variable() { variables "$@"; }
variables()
{
- trace_filter variables
+ trace_filter variables || set -o xtrace
local _command _variables=() _type __variables_commands
_variables=()
View
2 core/internal/shell/config/functions
@@ -56,7 +56,7 @@ __sm.config.write()
__sm.config.settings.search()
{
- trace_filter config_search
+ trace_filter config_search || set -o xtrace
local extension setting _path paths
extension=$1
View
6 core/internal/shell/extensions/cache/functions
@@ -11,7 +11,7 @@ __sm.cache.map.add()
# Step 1 collect direct filesystem mapping
__sm.cache.map.filesystem.initialize()
{
- trace_filter action_detection
+ trace_filter action_detection || set -o xtrace
local _action_path _file_name
if [[ -d "${_actions_root}" ]]
@@ -35,7 +35,7 @@ __sm.cache.map.filesystem.initialize()
# Step 2 read map
__sm.cache.map.actions.initialize()
{
- trace_filter action_detection
+ trace_filter action_detection || set -o xtrace
local _mapping
if [[ -f "${_map}" ]]
then
@@ -56,7 +56,7 @@ __sm.module.detect.actions()
# Step 3 collect dependent modules mapping
__sm.cache.map.modules.initialize()
{
- trace_filter action_detection
+ trace_filter action_detection || set -o xtrace
local _modules _module_path _module_name _action_pair
if [[ ! -d "${_modules_root}" ]]
View
4 core/internal/shell/extensions/completion/functions
@@ -2,7 +2,7 @@
find_starting_action()
{
- trace_filter action_completion
+ trace_filter action_completion || set -o xtrace
extensions_path="$1" extension="$2"
shift || __sm.log.fail "Cannot detect extension existence;"\
" No extension path was given."
@@ -63,7 +63,7 @@ show_extension_names()
extension_action_completion()
{
- trace_filter action_completion
+ trace_filter action_completion || set -o xtrace
local _action_found _extension_found _extension_found_path cut_count last_char _args
_action_found=0
_extension_found=0
View
6 core/internal/shell/extensions/detection/functions
@@ -2,7 +2,7 @@
__sm.cache.map.check()
{
- trace_filter action_detection
+ trace_filter action_detection || set -o xtrace
local _found_actions _method _name _item _candidate _candidates screen_height
_found_actions=()
@@ -56,7 +56,7 @@ __sm.cache.map.check()
__sm.extension.actions.find()
{
- trace_filter action_detection
+ trace_filter action_detection || set -o xtrace
extensions_path="$1" extension="$2"
shift || __sm.log.fail "Extension path must be given as the first parameter."
@@ -115,7 +115,7 @@ __sm.extension.actions.find()
__sm.extension.action()
{
- trace_filter action_detection
+ trace_filter action_detection || set -o xtrace
(( extension_action_calls == 0 )) ||
__sm.log.fail "Cannot call a 2nd time, args: ${extension_args[*]}"
View
4 core/internal/shell/extensions/execution/functions
@@ -89,7 +89,7 @@ __sm.extension.modules.include()
__sm.extension.action.prerequisites()
{
- trace_filter action_pre
+ trace_filter action_pre || set -o xtrace
local _pre _name _action _extension
_action="${action// *}"
_extension="${extension// *}"
@@ -130,7 +130,7 @@ __sm.extension.action.prerequisites()
__sm.extension.run()
{
- trace_filter extension_run
+ trace_filter extension_run || set -o xtrace
local _type _path _namespaces
_type="${action_type:-}"
View
2 core/internal/shell/files/functions
@@ -79,7 +79,7 @@ __sm.files.remove()
__sm.files.create()
{
- trace_filter filesystem
+ trace_filter filesystem || set -o xtrace
local _file _path _files
_files=("$@")
shift || __sm.log.fail "Cannot ensure files exist; No files were given."
View
4 core/internal/shell/paths/functions
@@ -125,7 +125,7 @@ __sm.paths.copy()
__sm.paths.chown()
{
- trace_filter filesystem
+ trace_filter filesystem || set -o xtrace
local _identity _flags _path _command
_identity="$1"
_flags="$2"
@@ -148,7 +148,7 @@ __sm.paths.chown()
__sm.paths.chmod()
{
- trace_filter filesystem
+ trace_filter filesystem || set -o xtrace
local _mode _flags
_mode="$1"
_flags="$2"
View
5 core/internal/shell/user/functions
@@ -223,6 +223,11 @@ __sm.user.is.root()
(( UID == __sm_user_id_root ))
}
+__sm.user.is.not.root()
+{
+ (( UID != __sm_user_id_root ))
+}
+
__sm.user.is.privileged()
{
(( UID < __sm_user_id_users ))
View
10 core/internal/shell/variables/functions
@@ -2,7 +2,7 @@
__sm.variables.are.nonempty()
{
- trace_filter variables
+ trace_filter variables || set -o xtrace
local _variable _variables
_variables=("$@")
shift || __sm.log.fail "Cannot check if variables are nonempty; No variables were given."
@@ -16,7 +16,7 @@ __sm.variables.are.nonempty()
__sm.variables.are.empty()
{
- trace_filter variables
+ trace_filter variables || set -o xtrace
local _variable
_variable="${1:-}"
shift || __sm.log.fail "Cannot check if variable is empty, as no variable was given."
@@ -25,7 +25,7 @@ __sm.variables.are.empty()
__sm.variables.filter()
{
- trace_filter variables
+ trace_filter variables || set -o xtrace
__sm_variables_empty=()
__sm_variables_nonempty=()
@@ -43,7 +43,7 @@ __sm.variables.filter()
__sm.variables.must.be.nonempty()
{
- trace_filter variables
+ trace_filter variables || set -o xtrace
local _error IFS
_error="$1"
IFS=','
@@ -59,7 +59,7 @@ __sm.variables.must.be.nonempty()
__sm.variables.must.be.empty()
{
- trace_filter variables
+ trace_filter variables || set -o xtrace
local _error IFS
_error="$1"
IFS=','
View
2 core/internal/shell/vcs/functions
@@ -18,7 +18,7 @@ internal_vcs_initialize()
fetch_uri()
{
- trace_filter vcs
+ trace_filter vcs || set -o xtrace
fetch_error_initialize "$@"
local vcs_initial_pwd _uri _target _args
View
38 core/sm/shell/log/functions
@@ -111,23 +111,23 @@ log_step()
__sm.log.step "$@"
}
-trace_filter()
+__sm.trace_filter()
{
- set +o xtrace
if [[ -n "$1" ]]
then
if [[ -n "${BASH_VERSION}" ]]
then
- __sm.log.trace.filter start "$state" "${FUNCNAME[1]}=$1"
+ __sm.log.trace.filter start "${FUNCNAME[1]}=$1"
elif [[ -n "${ZSH_VERSION}" ]]
then
#true # no-op for now
- __sm.log.trace.filter start "$state" "${funcstack[2]}=$1"
+ __sm.log.trace.filter start "${funcstack[1]}=$1"
fi
else
- __sm.log.trace.filter stop "$state" "${__sm_trace_filter_stack[@]}"
+ __sm.log.trace.filter stop "${__sm_trace_filter_stack[@]}"
fi
}
+alias trace_filter='set +o xtrace ; __sm.trace_filter'
# Examples
#
@@ -178,7 +178,7 @@ trace_filter()
# ### Code Walkthrough
backtrace()
{
- trace_filter backtrace # backtrace is disabled by default.
+ trace_filter backtrace || set -o xtrace # backtrace is disabled by default.
local _separator _columns _stack _trace _message _flag _source _function _line \
_index _largest _format _digits _longest _string \
@@ -497,7 +497,7 @@ __sm.log.trace.filter()
_name="${FUNCNAME[2]}"
elif [[ -n "${ZSH_VERSION}" ]]
then
- _name="${funcstack[3]}"
+ _name="${funcstack[2]}"
fi
if [[ "${_name}" == "${old}" ]]
@@ -515,29 +515,15 @@ __sm.log.trace.filter()
if [[ -n "$filter" ]]
then
- if [[ -n "${BASH_VERSION}" ]]
+ if __sm.log.options.check "$trace_flags" "${filter##*=}"
then
- if __sm.log.options.check "$trace_flags" "${filter##*=}"
- then
- trap 'set +o xtrace "\$?=$?" ; trace_filter' RETURN
- elif [[ -n "${ZSH_VERSION}" ]]
- then
- true # what to do...
- fi
- set -o xtrace
+ return 1
fi
else
# No param, restore default state
if (( trace_flag != 0 ))
then
- if [[ -n "${BASH_VERSION}" ]]
- then
- trap 'set +o xtrace "\$?=$?" ; trace_filter' RETURN
- elif [[ -n "${ZSH_VERSION}" ]]
- then
- true # what to do...
- fi
- set -o xtrace
+ return 1
fi
fi
}
@@ -586,7 +572,7 @@ __sm.log.search()
__sm.actions.call()
{
- trace_filter action
+ trace_filter action || set -o xtrace
"$@"
}
@@ -596,7 +582,7 @@ __sm.actions.source()
script="$1"
shift || __sm.log.fail "No script was given as the first parameter."
[[ -r "$script" ]] || __sm.log.fail "Could not find script to run: $script."
- trace_filter action
+ trace_filter action || set -o xtrace
source "$script"
}
View
2 core/sm/shell/versionedfs/functions
@@ -44,7 +44,7 @@
#
versionedfs()
{
- trace_filter versionedfs
+ trace_filter versionedfs || set -o xtrace
local _token _path _paths _source _name _version _strategy _method _activate _action
_action="${1:-}"

0 comments on commit e4e7311

Please sign in to comment.
Something went wrong with that request. Please try again.