flip read to file if its not a pipe
This commit is contained in:
@@ -30,6 +30,7 @@ _help() {
|
||||
echo my data | $SELF 1 # writes data with name: 1
|
||||
$SELF 1 | cat - # prints the contents of file: 1
|
||||
$SELF w file.ext # sends file keeping its name
|
||||
$SELF r file.ext # download file with same name
|
||||
|
||||
Config:
|
||||
set: FLEES_ROOTURL, FLEES_SHARE, FLEES_TOKEN
|
||||
@@ -104,14 +105,23 @@ _write_stdin() { # name
|
||||
}
|
||||
|
||||
_read() {
|
||||
[[ -z "$FILE" ]] && stream_out=1
|
||||
[[ "$FILE" = "-" ]] && stream_out=1
|
||||
[ -t 1 ] || stream_out=1
|
||||
|
||||
[[ "$stream_out" -eq 1 ]] && {
|
||||
_read_stdout "$NAME"
|
||||
} || {
|
||||
_read_file "$NAME" "$FILE"
|
||||
return
|
||||
}
|
||||
# no file mentioned, use the name as file
|
||||
[[ -z "$FILE" ]] && {
|
||||
[[ -n "$NAME" ]] && {
|
||||
FILE=$( basename "$NAME" )
|
||||
}
|
||||
[[ -e "$FILE" ]] && {
|
||||
echo "'$FILE' already exists, not overwriting"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
_read_file "$NAME" "$FILE"
|
||||
}
|
||||
|
||||
_read_file() { # name, file
|
||||
|
||||
Reference in New Issue
Block a user