diff --git a/astronaut/astronaut b/astronaut/astronaut index 08af699..ee6e3af 100755 --- a/astronaut/astronaut +++ b/astronaut/astronaut @@ -161,7 +161,7 @@ safe_sed() { download() { mkdir -p "$dir_source/$name" - local filename="$(basename $(echo "$1" | cut -d? -f1))" + [ "$3" ] && local filename="$3" || local filename="$(basename $(echo "$1" | cut -d? -f1))" local path="$dir_source/$name/$filename" [ "$2" -a -f "$path" ] && local checksum="$(_mksum "$path")" @@ -169,7 +169,7 @@ download() { if [ ! -e "$path" -o "$checksum" != "$2" ]; then _msg "Downloading $filename" - [ "$3" ] && local cmd="$3" || local cmd="$cmd_download" + [ "$4" ] && local cmd="$4" || local cmd="$cmd_download" eval $(echo "$cmd" | sed -e "s/{dst}/'$(safe_sed "$path")'/g" -e "s/{src}/'$(safe_sed "$1")'/g") checksum="$(_mksum "$path")" diff --git a/astronaut/examples/hello.sat b/astronaut/examples/hello.sat index a3eef67..9e9dfec 100644 --- a/astronaut/examples/hello.sat +++ b/astronaut/examples/hello.sat @@ -44,9 +44,10 @@ define_option 'test=Default value' # It is also allowed to provide no descripti # - options # Get them files. -# URL [REQUIRED], MD5sum, Custom command +# URL [REQUIRED], MD5sum, Custom filename, Custom command download "https://ftp.gnu.org/gnu/$name/$name-$version.tar.gz" \ '6cd0ffea3884a4e79330338dcc2987d6' \ + "$name-$version.tar.gz" \ 'curl -L -o {dst} {src}' # Abbreviation download and extract. Does not allow custom commands.