example on home page has extraneous echo #322

Closed
opened 2026-01-19 18:29:53 +00:00 by michael · 3 comments
Owner

Originally created by @dmd on GitHub.

image

Usage:\necho transfer should just be Usage:\ntransfer

Originally created by @dmd on GitHub. ![image](https://user-images.githubusercontent.com/41439/41678976-abadaa3a-749a-11e8-98bc-edaf0da0cf31.png) `Usage:\necho transfer ` should just be `Usage:\ntransfer `
Author
Owner

@qoomon commented on GitHub:

If anybody fixes this please remove the temp files creation in favor of the following snippet.


transfer() { 
    # check arguments
    if [ $# -eq 0 ]; then 
        echo "No arguments specified."
        echo "Usage:"
        echo "  transfer <file|directory>"
        echo "  ... | transfer <file_name>"
        return 1
    fi
    
    # upload stdin or file
    if tty -s; then 
        file="$1"
        if [ ! -e "$file" ]; then
            echo "$file: No such file or directory"
            return 1
        fi
        
        file_name=$(basename "$file" | sed -e 's/[^a-zA-Z0-9._-]/-/g') 
        
        # upload file or directory
        if [ -d "$file" ]; then
            # transfer directory
            file_name="$file_name.zip" 
            (cd "$file" && zip -r -q - .) | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null
        else 
            # transfer file
            cat "$file" | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null
        fi
    else 
        # transfer pipe
        file_name=$1
        curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null
    fi
} 
@qoomon commented on GitHub: If anybody fixes this please remove the temp files creation in favor of the following snippet. ```shell transfer() { # check arguments if [ $# -eq 0 ]; then echo "No arguments specified." echo "Usage:" echo " transfer <file|directory>" echo " ... | transfer <file_name>" return 1 fi # upload stdin or file if tty -s; then file="$1" if [ ! -e "$file" ]; then echo "$file: No such file or directory" return 1 fi file_name=$(basename "$file" | sed -e 's/[^a-zA-Z0-9._-]/-/g') # upload file or directory if [ -d "$file" ]; then # transfer directory file_name="$file_name.zip" (cd "$file" && zip -r -q - .) | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null else # transfer file cat "$file" | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null fi else # transfer pipe file_name=$1 curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null fi } ```
Author
Owner

@qoomon commented on GitHub:

@aspacca okay.

@qoomon commented on GitHub: @aspacca okay.
Author
Owner

@paolafrancesca commented on GitHub:

@qoomon you can open a PR on https://github.com/dutchcoders/transfer.sh-web and I will merge

the files are https://github.com/dutchcoders/transfer.sh-web/blob/master/src/index.txt and https://github.com/dutchcoders/transfer.sh-web/blob/master/src/index.html

I see you already commented on the gist with the version without tmpfile

@paolafrancesca commented on GitHub: @qoomon you can open a PR on https://github.com/dutchcoders/transfer.sh-web and I will merge the files are https://github.com/dutchcoders/transfer.sh-web/blob/master/src/index.txt and https://github.com/dutchcoders/transfer.sh-web/blob/master/src/index.html I see you already commented on the gist with the version without tmpfile
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dutchcoders/transfer.sh#322