flip writing when in scripts
This commit is contained in:
@@ -72,6 +72,8 @@ _simple_list() {
|
||||
}
|
||||
|
||||
_write() {
|
||||
# stdin is open
|
||||
[ -t 0 ] || stream_in=1
|
||||
# no file mentioned, use the name as file
|
||||
[[ -z "$FILE" ]] && {
|
||||
[[ -e "$NAME" ]] && {
|
||||
@@ -80,24 +82,28 @@ _write() {
|
||||
NAME=$( basename "$NAME" )
|
||||
}
|
||||
}
|
||||
# stdin is open, use stdin
|
||||
[ -t 0 ] || stream_in=1
|
||||
[[ -e "$FILE" ]] && {
|
||||
# Input file exists, dont use stream
|
||||
stream_in=0
|
||||
}
|
||||
|
||||
[ -t 0 ] && [[ -z "$FILE" ]] && {
|
||||
[[ $stream_in -ne 1 ]] && [[ -z "$FILE" ]] && {
|
||||
_msg File to read needed, or use stdin
|
||||
exit 1
|
||||
}
|
||||
_msg "Writing $NAME"
|
||||
[[ "$stream_in" -eq 1 ]] && {
|
||||
_write_stdin "$NAME"
|
||||
} || {
|
||||
[[ -d "$FILE" ]] && {
|
||||
[[ "${NAME,,}" = *".tar" ]] || NAME="${NAME}".tar
|
||||
_write_folder "$NAME" "$FILE"
|
||||
} || {
|
||||
_write_file "$NAME" "$FILE"
|
||||
}
|
||||
return $?
|
||||
}
|
||||
|
||||
[[ -d "$FILE" ]] && {
|
||||
[[ "${NAME,,}" = *".tar" ]] || NAME="${NAME}".tar
|
||||
_write_folder "$NAME" "$FILE"
|
||||
return $?
|
||||
}
|
||||
|
||||
_write_file "$NAME" "$FILE"
|
||||
}
|
||||
|
||||
_write_folder() { # name, file
|
||||
|
||||
Reference in New Issue
Block a user