Skip to content

Improve transfer function to support stdin#45

Open
anihm136 wants to merge 1 commit intodutchcoders:masterfrom
anihm136:master
Open

Improve transfer function to support stdin#45
anihm136 wants to merge 1 commit intodutchcoders:masterfrom
anihm136:master

Conversation

@anihm136
Copy link

Fixes dutchcoders/transfer.sh#413

Allows transfer function to take input from stdin

@francescayeye
Copy link
Collaborator

hello @anihm136

sorry for the long time taking to review your PR

$ source .bash_profile
-bash: .bash_profile: line 1: syntax error near unexpected token `('
-bash: .bash_profile: line 1: `transfer() { local file local file_name file="§1" [ -n "§file" ] && file_name=§(basename "§file") || file_name="" if tty -s; then if [ §# -eq 0 ]; then echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>" >&2 return 1 fi if [ ! -e "§file" ]; then echo "§file: No such file or directory" >&2 return 1 fi if [ -d "§file" ]; then file_name="§file_name.zip" , (cd "§file" && zip -r -q - .) | curl --progress-bar --upload-file "-" "https://transfer.sh/§file_name" | tee /dev/null,         else              cat "§file" | curl --progress-bar --upload-file "-" "https://transfer.sh/§file_name" | tee /dev/null         fi else if [ -z "§file_name" ] && [ ! -t 0 ]; then file_name=§(mktemp -u "tmpXXXXXXXXXX") elif [ -t 0 ]; then echo "No data provided.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>" >&2 return 1 fi curl --progress-bar --upload-file "-" "https://transfer.sh/§file_name" | tee /dev/null fi }'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Read in from stdin/pipe

2 participants