Browse Source

Expose safe_sed to satellites

master
mid-kid 8 years ago
parent
commit
2bde31c2fa
  1. 11
      astronaut/astronaut
  2. 4
      astronaut/hello.sat

11
astronaut/astronaut

@ -135,7 +135,7 @@ _mksum() {
echo "$(md5sum "$@" 2> /dev/null | cut -d' ' -f1)" echo "$(md5sum "$@" 2> /dev/null | cut -d' ' -f1)"
} }
_safe_sed() { safe_sed() {
echo "$1" | sed 's/[[\.*^$/]/\\&/g' echo "$1" | sed 's/[[\.*^$/]/\\&/g'
} }
@ -151,7 +151,7 @@ download() {
_msg "Downloading $filename" _msg "Downloading $filename"
[ "$3" ] && local cmd="$3" || local cmd="$cmd_download" [ "$3" ] && local cmd="$3" || local cmd="$cmd_download"
eval $(echo "$cmd" | sed -e "s@{dst}@'$(_safe_sed "$path")'@g" -e "s@{src}@'$(_safe_sed "$1")'@g") eval $(echo "$cmd" | sed -e "s/{dst}/'$(safe_sed "$path")'/g" -e "s@{src}@'$(safe_sed "$1")'@g")
checksum="$(_mksum "$path")" checksum="$(_mksum "$path")"
if [ "$2" -a "$checksum" != "$2" ]; then if [ "$2" -a "$checksum" != "$2" ]; then
@ -165,7 +165,7 @@ extract() {
_msg "Extracting $1" _msg "Extracting $1"
[ "$2" ] && local dest="$2" || local dest='.' [ "$2" ] && local dest="$2" || local dest='.'
[ "$3" ] && local cmd="$3" || local cmd="$cmd_extract" [ "$3" ] && local cmd="$3" || local cmd="$cmd_extract"
eval $(echo "$cmd" | sed -e "s@{src}@'$dir_source/$name/$1'@g" -e "s@{dst}@'$dest'@g") eval $(echo "$cmd" | sed -e "s/{src}/'$(safe_sed "$dir_source/$name/$1")'/g" -e "s/{dst}/'$(safe_sed "$dest")'/g")
} }
getfile() { getfile() {
@ -206,7 +206,8 @@ option() {
local enabled=false local enabled=false
local opt local opt
local IFS=','; for option in $options; do local IFS=','
for option in $options; do
local option_negate=false local option_negate=false
case "$option" in case "$option" in
*=*) *=*)
@ -301,7 +302,7 @@ dir_source="$(realpath "$dir_source")"
if [ "$_download_only" = false ]; then if [ "$_download_only" = false ]; then
# Fix up the install path # Fix up the install path
dir_install="$(echo "$dir_install" | sed -e "s@{pkg}@$(_safe_sed "$satname")@g")" dir_install="$(echo "$dir_install" | sed -e "s/{pkg}/$(safe_sed "$satname")/g")"
# This variable can be set by a wrapper script in need to nuke the install dir. # This variable can be set by a wrapper script in need to nuke the install dir.
if [ "$_nuke_dir_install" = true -a ! -z "$dir_install" ]; then if [ "$_nuke_dir_install" = true -a ! -z "$dir_install" ]; then

4
astronaut/hello.sat

@ -96,4 +96,8 @@ rm "$dir_install/$dir_prefix/share/info/dir" # This file collides with some oth
# Call the function we imported. For more info see the top of the file, and functions/say_hello.sh # Call the function we imported. For more info see the top of the file, and functions/say_hello.sh
say_hello say_hello
# Misc functions:
#safe_sed 'oh/i/hope\i\canuse%&thisinsed'
# Escapes all the necessary characters to be able to use it in a regular sed command
# vim:set tabstop=4 shiftwidth=4 syntax=sh et: # vim:set tabstop=4 shiftwidth=4 syntax=sh et:

Loading…
Cancel
Save