diff options
author | Egor Tensin <egor@tensin.name> | 2025-08-26 16:50:44 +0200 |
---|---|---|
committer | Egor Tensin <egor@tensin.name> | 2025-08-26 16:50:44 +0200 |
commit | e4abbd87c69018408e30e6b0342e826324829353 (patch) | |
tree | 799885e3a995bb1a1e6a95d2315755029cb5b250 | |
parent | ssh: restore GitHub key (diff) | |
download | linux-home-e4abbd87c69018408e30e6b0342e826324829353.tar.gz linux-home-e4abbd87c69018408e30e6b0342e826324829353.zip |
-rw-r--r-- | %HOME%/.bash_utils/file.sh | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/%HOME%/.bash_utils/file.sh b/%HOME%/.bash_utils/file.sh index 94d297d..a433efc 100644 --- a/%HOME%/.bash_utils/file.sh +++ b/%HOME%/.bash_utils/file.sh @@ -42,12 +42,15 @@ pastebin() ( set -o errexit -o nounset -o pipefail shopt -s inherit_errexit 2> /dev/null || true - if [ "$#" -ne 1 ]; then - echo "usage: ${FUNCNAME[0]} PATH" >&2 + if [ "$#" -gt 1 ]; then + echo "usage: ${FUNCNAME[0]} [PATH]" >&2 return 1 fi - local path="$1" + local data_arg='@-' + if [ "$#" -gt 0 ]; then + data_arg="@$1" + fi - curl -sS --connect-timeout 5 -X PUT --data-binary "@$path" https://paste.tensin.name/ + curl -sS --connect-timeout 5 -X PUT --data-binary "$data_arg" https://paste.tensin.name/ ) |