Compare commits
9 Commits
58cc76c317
...
60dfe19049
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60dfe19049 | ||
|
|
c32771a4ff | ||
|
|
080511d0bd | ||
|
|
d8bdfefdf1 | ||
|
|
5f5f9c0e71 | ||
|
|
30387a4f08 | ||
|
|
0c51363d86 | ||
|
|
043fbaef0b | ||
|
|
ed5587712e |
11
profile.conf
11
profile.conf
@@ -1,6 +1,6 @@
|
|||||||
[system]
|
[system]
|
||||||
# System section is used to set Bash behavior and other system related variables,
|
# System section is used to set Bash behavior and other system related
|
||||||
# such as the default pager, the terminal type, etc.
|
# variables, such as the default pager, the terminal type, etc.
|
||||||
# Set bash history
|
# Set bash history
|
||||||
HISTSIZE=50000
|
HISTSIZE=50000
|
||||||
HISTIGNORE="&:[bf]g:exit"
|
HISTIGNORE="&:[bf]g:exit"
|
||||||
@@ -17,6 +17,10 @@ TERM=xterm-256color
|
|||||||
[debug]
|
[debug]
|
||||||
# Section used by debug.sh
|
# Section used by debug.sh
|
||||||
|
|
||||||
|
[disp]
|
||||||
|
# Section used by disp.sh
|
||||||
|
# NO_COLOR=1 # Set to any value to disable colors in disp output
|
||||||
|
|
||||||
[filefct]
|
[filefct]
|
||||||
# Section used by filefct.sh
|
# Section used by filefct.sh
|
||||||
|
|
||||||
@@ -25,8 +29,7 @@ TERM=xterm-256color
|
|||||||
|
|
||||||
[info]
|
[info]
|
||||||
# Section used by info.sh
|
# Section used by info.sh
|
||||||
# Default city for weather forcast
|
DEFAULT_CITY="Toulouse" # Default city for weather forcast
|
||||||
DEFAULT_CITY="Toulouse"
|
|
||||||
|
|
||||||
[lang]
|
[lang]
|
||||||
# Section used by lang.sh
|
# Section used by lang.sh
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
@@ -208,7 +208,22 @@ utaz()
|
|||||||
disp E "The --create-dir and --no-dir options are mutually exclusive."
|
disp E "The --create-dir and --no-dir options are mutually exclusive."
|
||||||
|
|
||||||
for zitem in "${FILES[@]}"; do
|
for zitem in "${FILES[@]}"; do
|
||||||
for f in "${zitem}"/*; do
|
# Build list of input files to process, with whitespace-safe handling.
|
||||||
|
local targets=()
|
||||||
|
if [[ -f "$zitem" ]]; then
|
||||||
|
targets=("$zitem")
|
||||||
|
elif [[ -d "$zitem" ]]; then
|
||||||
|
mapfile -d '' -t targets < <(find "$zitem" -mindepth 1 -maxdepth 1 -print0 2>/dev/null)
|
||||||
|
if [[ ${#targets[@]} -eq 0 ]]; then
|
||||||
|
disp I "Directory ${zitem} is empty, skipping."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
disp W "Path ${zitem} is not a file or directory, skipping."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
for f in "${targets[@]}"; do
|
||||||
local dir="${f%.*}"
|
local dir="${f%.*}"
|
||||||
local extractor=""
|
local extractor=""
|
||||||
case "$f" in
|
case "$f" in
|
||||||
@@ -269,21 +284,21 @@ utaz()
|
|||||||
# Verify binary existence
|
# Verify binary existence
|
||||||
local cmd=${extractor//_un/}
|
local cmd=${extractor//_un/}
|
||||||
if [[ $cmd == "deb" ]]; then
|
if [[ $cmd == "deb" ]]; then
|
||||||
command -v dpkg-deb >/dev/null 2>&1 || {
|
command -v -- dpkg-deb >/dev/null 2>&1 || {
|
||||||
disp E "The program 'dpkg-deb' is not installed, aborting."
|
disp E "The program 'dpkg-deb' is not installed, aborting."
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
elif [[ $cmd == "rpm" ]]; then
|
elif [[ $cmd == "rpm" ]]; then
|
||||||
command -v rpm2cpio >/dev/null 2>&1 || {
|
command -v -- rpm2cpio >/dev/null 2>&1 || {
|
||||||
disp E "The program 'rpm2cpio' is not installed, aborting."
|
disp E "The program 'rpm2cpio' is not installed, aborting."
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
command -v cpio >/dev/null 2>&1 || {
|
command -v -- cpio >/dev/null 2>&1 || {
|
||||||
disp E "The program 'cpio' is not installed, aborting."
|
disp E "The program 'cpio' is not installed, aborting."
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
command -v ${cmd} >/dev/null 2>&1 || {
|
command -v -- "${cmd}" >/dev/null 2>&1 || {
|
||||||
disp E "Binary ${cmd} necessary to extract ${f} is missing."
|
disp E "Binary ${cmd} necessary to extract ${f} is missing."
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -318,7 +333,12 @@ utaz()
|
|||||||
if [[ -n ${createdir} ]]; then
|
if [[ -n ${createdir} ]]; then
|
||||||
disp I "Archive extracted successfully in subdirectory."
|
disp I "Archive extracted successfully in subdirectory."
|
||||||
elif [[ -n ${nodir} ]]; then
|
elif [[ -n ${nodir} ]]; then
|
||||||
mv "./${dir}/"* ./ && rmdir "${dir}"
|
shopt -s nullglob
|
||||||
|
for child in "${dir}"/*; do
|
||||||
|
mv -- "$child" .
|
||||||
|
done
|
||||||
|
shopt -u nullglob
|
||||||
|
rmdir -- "${dir}"
|
||||||
disp I "Archive extracted successfully, no subdirectory needed."
|
disp I "Archive extracted successfully, no subdirectory needed."
|
||||||
else
|
else
|
||||||
# Set nullglob to ensure the array is empty if no files match
|
# Set nullglob to ensure the array is empty if no files match
|
||||||
@@ -328,7 +348,12 @@ utaz()
|
|||||||
# Check if exactly one item exists and if that item is a directory
|
# Check if exactly one item exists and if that item is a directory
|
||||||
if [[ ${#contents[@]} -eq 1 ]] && [[ -d "${contents[0]}" ]]; then
|
if [[ ${#contents[@]} -eq 1 ]] && [[ -d "${contents[0]}" ]]; then
|
||||||
# Single directory detected
|
# Single directory detected
|
||||||
mv "${contents[0]}"/* ./ && rmdir "${dir}"
|
shopt -s nullglob
|
||||||
|
for child in "${contents[0]}"/*; do
|
||||||
|
mv -- "$child" .
|
||||||
|
done
|
||||||
|
shopt -u nullglob
|
||||||
|
rmdir -- "${dir}"
|
||||||
disp I "Archive extracted successfully, no subdirectory needed."
|
disp I "Archive extracted successfully, no subdirectory needed."
|
||||||
else
|
else
|
||||||
disp I "Archive extracted successfully in subdirectory."
|
disp I "Archive extracted successfully in subdirectory."
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
@@ -46,7 +46,7 @@ function backtrace()
|
|||||||
"${FUNCNAME[$i]}" "${BASH_SOURCE[$i]}" "${BASH_LINENO[$(( i-1 ))]}"
|
"${FUNCNAME[$i]}" "${BASH_SOURCE[$i]}" "${BASH_LINENO[$(( i-1 ))]}"
|
||||||
((i++))
|
((i++))
|
||||||
done
|
done
|
||||||
unset func i
|
unset i
|
||||||
printf "==============================\n"
|
printf "==============================\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,30 +69,37 @@ settrace()
|
|||||||
#trap -p ERR
|
#trap -p ERR
|
||||||
|
|
||||||
local PARSED
|
local PARSED
|
||||||
PARSED=$(getopt -oh --long help,on,off,status -- "$@")
|
PARSED=$(getopt -oh --long help,on,off,status,force -- "$@")
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
disp E "Invalid options, use \"settrace --help\" to display usage."
|
disp E "Invalid options, use \"settrace --help\" to display usage."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
eval set -- "$PARSED"
|
eval set -- "$PARSED"
|
||||||
|
local force=0
|
||||||
while true; do
|
while true; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
printf "Try to activate backtrace display for script debugging.\n\n"
|
printf "Try to activate backtrace display for script debugging.\n\n"
|
||||||
printf "Options:\n"
|
printf "Options:\n"
|
||||||
printf "\t--on\t\tActivate backtrace generation\n"
|
printf "\t--on\t\tActivate backtrace generation\n"
|
||||||
|
printf "\t--force\t\tForce replacement of existing trap (use with --on)\n"
|
||||||
printf "\t--off\t\tDeactivate backtrace generation\n\n"
|
printf "\t--off\t\tDeactivate backtrace generation\n\n"
|
||||||
printf "That function active a trap event on error. If the script you want to\n"
|
printf "That function active a trap event on error. If the script you want to\n"
|
||||||
printf "debug overload the ERR bash trap, it will not work.\n"
|
printf "debug overload the ERR bash trap, it will not work.\n"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--on)
|
--on)
|
||||||
if [[ ${status} == "on" ]]; then
|
if [[ ${status} == "on" ]] && [[ $force -eq 0 ]]; then
|
||||||
disp W "ERR signal trap is already set, replacing previous trap!"
|
disp E "ERR signal trap is already set. Use --force to replace it."
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
trap "error" ERR
|
trap "error" ERR
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--force)
|
||||||
|
force=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--off)
|
--off)
|
||||||
if [[ ${status} != "on" ]]; then
|
if [[ ${status} != "on" ]]; then
|
||||||
disp W "ERR signal trap is already unset!"
|
disp W "ERR signal trap is already unset!"
|
||||||
@@ -101,7 +108,7 @@ settrace()
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--status)
|
--status)
|
||||||
disp "ERR trap signal is ${status}."
|
disp I "Trap signal is ${status}."
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
@@ -114,7 +121,7 @@ settrace()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
unset status
|
unset status force
|
||||||
}
|
}
|
||||||
export -f settrace
|
export -f settrace
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
@@ -124,25 +124,45 @@ export On_IWhite='\e[0;107m'
|
|||||||
# D : debug (cyan)
|
# D : debug (cyan)
|
||||||
disp()
|
disp()
|
||||||
{
|
{
|
||||||
case $1 in
|
# Handle NO_COLOR: disable colors if set
|
||||||
|
local color_enabled=1
|
||||||
|
[[ -n $NO_COLOR ]] && color_enabled=0
|
||||||
|
|
||||||
|
case ${1^^} in
|
||||||
"I")
|
"I")
|
||||||
local heads="[ ${IGreen}info${DEFAULTFG} ]"
|
if [[ $color_enabled -eq 1 ]]; then
|
||||||
|
local heads="[ ${IGreen}info${DEFAULTFG} ]"
|
||||||
|
else
|
||||||
|
local heads="[ info ]"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
[[ -z $QUIET || $QUIET -ne 1 ]] && \
|
[[ -z $QUIET || $QUIET -ne 1 ]] && \
|
||||||
printf "%b\n" "${heads} $*${RESETCOL}"
|
printf "%b\n" "${heads} $*${RESETCOL}"
|
||||||
;;
|
;;
|
||||||
"W")
|
"W")
|
||||||
local heads="[ ${IYellow}Warning${DEFAULTFG} ]"
|
if [[ $color_enabled -eq 1 ]]; then
|
||||||
|
local heads="[ ${IYellow}Warning${DEFAULTFG} ]"
|
||||||
|
else
|
||||||
|
local heads="[ Warning ]"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
printf "%b\n" "${heads} $*${RESETCOL}" >&2
|
printf "%b\n" "${heads} $*${RESETCOL}" >&2
|
||||||
;;
|
;;
|
||||||
"E")
|
"E")
|
||||||
local heads="[ ${IRed}ERROR${DEFAULTFG} ]"
|
if [[ $color_enabled -eq 1 ]]; then
|
||||||
|
local heads="[ ${IRed}ERROR${DEFAULTFG} ]"
|
||||||
|
else
|
||||||
|
local heads="[ ERROR ]"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
printf "%b\n" "${heads} $*${RESETCOL}" >&2
|
printf "%b\n" "${heads} $*${RESETCOL}" >&2
|
||||||
;;
|
;;
|
||||||
"D")
|
"D")
|
||||||
local heads="[ ${ICyan}debug${DEFAULTFG} ]"
|
if [[ $color_enabled -eq 1 ]]; then
|
||||||
|
local heads="[ ${ICyan}debug${DEFAULTFG} ]"
|
||||||
|
else
|
||||||
|
local heads="[ debug ]"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
[[ -n $DEBUG && $DEBUG -gt 1 ]] && \
|
[[ -n $DEBUG && $DEBUG -gt 1 ]] && \
|
||||||
printf "%b\n" "${heads} $*${RESETCOL}"
|
printf "%b\n" "${heads} $*${RESETCOL}"
|
||||||
@@ -157,4 +177,7 @@ export -f disp
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
# Load disp section variables
|
||||||
|
load_conf disp
|
||||||
|
|
||||||
# EOF
|
# EOF
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||||
# Protected by the BSD3 license. Please read bellow for details.
|
# Protected by the BSD3 license. Please read bellow for details.
|
||||||
#
|
#
|
||||||
# * Redistribution and use in source and binary forms,
|
# * Redistribution and use in source and binary forms,
|
||||||
|
|||||||
12
profile.sh
12
profile.sh
@@ -113,6 +113,15 @@ parse_conf()
|
|||||||
value="${value#"${value%%[![:space:]]*}"}"
|
value="${value#"${value%%[![:space:]]*}"}"
|
||||||
value="${value%$'\r'}"
|
value="${value%$'\r'}"
|
||||||
|
|
||||||
|
# Protect against command injection by disallowing certain characters in keys
|
||||||
|
value="${value//\`/}"
|
||||||
|
value="${value//\$\(/}"
|
||||||
|
|
||||||
|
# Correctly interpretet internal variables (e.g. $HOME)
|
||||||
|
if [[ "$value" == *\$* ]]; then
|
||||||
|
value=$(envsubst <<< "$value")
|
||||||
|
fi
|
||||||
|
|
||||||
# Strip quotes (handling both " and ')
|
# Strip quotes (handling both " and ')
|
||||||
value="${value%\"}"; value="${value#\"}"
|
value="${value%\"}"; value="${value#\"}"
|
||||||
value="${value%\'}"; value="${value#\'}"
|
value="${value%\'}"; value="${value#\'}"
|
||||||
@@ -122,7 +131,8 @@ parse_conf()
|
|||||||
current_array["$key"]="$value"
|
current_array["$key"]="$value"
|
||||||
fi
|
fi
|
||||||
done < "$config_file"
|
done < "$config_file"
|
||||||
}# ------------------------------------------------------------------------------
|
}
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user