paste script

From eeew, 10 Years ago, written in Plain Text, viewed 665 times.
URL https://paste.godclan.hu/view/NtQI1IGv Embed
Download Paste or View Raw
  1. #!/bin/sh
  2.  
  3. private=1
  4. lang=text
  5. author=$USER
  6. expire=
  7. reply=
  8. title=
  9.  
  10. OPTIND=1
  11. while getopts "pl:a:e:r:t:" opt; do
  12.     case "$opt" in
  13.     p)
  14.         private=0
  15.         ;;
  16.     l)
  17.         lang="$OPTARG"
  18.         ;;
  19.     a)
  20.         author="$OPTARG"
  21.         ;;
  22.     e)
  23.         expire="$OPTARG"
  24.         ;;
  25.     r)
  26.         reply="$OPTARG"
  27.         ;;
  28.     t)
  29.         title="$OPTARG"
  30.         ;;
  31.     esac
  32. done
  33.  
  34. shift $((OPTIND-1))
  35.  
  36. ARGS="-d 'name=$author' -d 'lang=$lang' -d 'private=$private'"
  37.  
  38. [ -n "$expire" ] && ARGS="$ARGS -d 'expire=$expire'"
  39. [ -n "$reply" ] && ARGS="$ARGS -d 'reply=$reply'"
  40. [ -n "$title" ] && ARGS="$ARGS -d 'title=$title'"
  41.  
  42. if [ -e "$1" ]; then
  43.     ARGS="$ARGS --data-urlencode 'text@$1'"
  44.     shift
  45. else
  46.     ARGS="$ARGS --data-urlencode text@-"
  47. fi
  48.  
  49. eval exec curl http://paste.godclan.hu/api/create $ARGS
  50.  
  51.  

Reply to "paste script"

Here you can reply to the paste above