add fileext function to helpers

master
Kebler Network System Administrator 2022-12-31 23:28:18 -08:00
parent bf62d67339
commit e2cade08c7
3 changed files with 37 additions and 31 deletions

View File

@ -82,6 +82,7 @@ for dir in ${1:-$BASH_SHELL_DIRS}; do
[[ "$dir" = "$BASH_SHELL_BASE" ]] && export BASH_SHELL_BASE_LOADED=true
done
# env | grep NETWORK
# # set one or the other of these in shell.env if you want to load networks with every shell
if [[ $BASH_SHELL_HOME_NETWORK_LOAD ]] || [[ $BASH_SHELL_ALL_NETWORKS_LOAD ]] || [[ $BASH_SHELL_NETWORKS_LOAD ]] ; then

View File

@ -21,6 +21,11 @@ filename() {
echo $(basename "$1" | rev | cut -f 2- -d '.' | rev)
}
fileext() {
# passed entire path
echo $1 | awk -F . '{print $NF}'
}
# // TODO remove and use path module
# // must change acl.lib and loginout, chromium, and ungoogled install files
adirname() {

View File

@ -1,4 +1,4 @@
#!/bin/bash
# !/bin/bash
# UCI SHELL REPOS ENVIRONMENT
# see README.md for details of how the system work
# In a nutshell its a set of directories that are sourced when creating a shell
@ -21,7 +21,7 @@
# if bash is not installed then don't bother to continue
! command -v bash >/dev/null 2>&1 && echo no bash command && return 1
export SHELL=$(command -v bash )
export SHELL="$(command -v bash )"
# without changing /etc/profile you can disable loading the UCI Shell system
# by uncommenting this line. It will only set up a simple prompt instead.
@ -41,13 +41,13 @@ fi
# within each of those directories if a load.sh exits it will be run
# otherwise files will be sourced according to load.sh in the base repo
export BASH_SHELL_LOAD=$BASH_SHELL_BASE/load.sh # load.sh is default
export BASH_SHELL_LOAD="$BASH_SHELL_BASE/load.sh" # load.sh is default"
export BASH_SHELL_STARTUP=$BASH_SHELL_BASE/startup.sh # startup.sh is default
export BASH_SHELL_STARTUP="$BASH_SHELL_BASE/startup.sh # startup.sh is default"
# for non-interactive login shells (like at boot)
# load this library that allows loading additional modules
export BASH_ENV=$BASH_SHELL_BASE/module.lib # module loading functions
export BASH_ENV="$BASH_SHELL_BASE/module.lib # module loading functions"
# otherwise comment above and uncommented next line
# export BASH_ENV=$BASH_SHELL_LOAD # load same as interactive shell, beware usually causes issues!!!
@ -75,10 +75,10 @@ export BASH_ENV=$BASH_SHELL_BASE/module.lib # module loading functions
BASH_SHELL_DIRS="$BASH_SHELL_BASE "
declare parent
parent=$(dirname $BASH_SHELL_BASE)
parent="$(dirname $BASH_SHELL_BASE)"
# Any Host
BASH_SHELL_ANY_HOST=${parent}/any/host # or set to
BASH_SHELL_ANY_HOST="${parent}/any/host # or set to"
# export BASH_SHELL_ALL_HOSTS=<some directory>
[[ -d $BASH_SHELL_ANY_HOST ]] && BASH_SHELL_DIRS+="$BASH_SHELL_ANY_HOST " && export BASH_SHELL_ANY_HOST
@ -101,7 +101,7 @@ BASH_SHELL_DEV=${BASH_SHELL_DEV:-/opt/shell}
[[ -d $BASH_SHELL_DEV ]] && export BASH_SHELL_DEV
# by default USER shell sources will be looked for under $HOME/shell
# export BASH_SHELL_USER_DIR=$HOME/shell
export BASH_SHELL_USER_DIR=$HOME/shell
# set up default location to look for other network shell directories
@ -128,16 +128,16 @@ source $BASH_SHELL_BASE/module.lib
# echo $BASH_SHELL_DIRS
# echo ---------------------------------
#archived ---for deletion or better explanation
# archived ---for deletion or better explanation
# echo enabling aliases with non-interactive shell
# DEPRECATED # export BASH_USE_ALIAS=true # will source aliases for non-interactive
# if not using implicit sourcing for non-interactive shells then one can do this per script
##################
# #################
# expanding aliases is optional
# shopt -s expand_aliases
# source $BASH_SHELL_LOAD
# < your script code >
# shopt -u expand_aliases
####################
# ###################