The little things give you away... A collection of various small helper stuff
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

28 lignes
1018 B

  1. #!/bin/bash
  2. if [[ "$#" -eq 0 || "$1" == '-h' || "$1" == '--help' ]]
  3. then
  4. echo 'Usage: curl-ia CURL-ARGUMENTS...' >&2
  5. echo 'Runs curl with the cookies from `ia`'"'s"' config file' >&2
  6. exit 1
  7. fi
  8. # Logic for the config file location is the same as upstream: the first one of $IA_CONFIG_FILE, ${XDG_CONFIG_HOME}/internetarchive/ia.ini, ~/.config/ia.ini, ~/.ia that exists is used.
  9. if [[ -z "${XDG_CONFIG_HOME}" || "${XDG_CONFIG_HOME}" != /* || ! -d "${XDG_CONFIG_HOME}" ]]
  10. then
  11. XDG_CONFIG_HOME="${HOME}/.config"
  12. fi
  13. for path in "${IA_CONFIG_FILE}" "${XDG_CONFIG_HOME}/internetarchive/ia.ini" ~/.config/ia.ini ~/.ia
  14. do
  15. if [[ -f "${path}" ]]
  16. then
  17. break
  18. fi
  19. done
  20. if [[ ! -f "${path}" ]]
  21. then
  22. echo 'Error: Could not find ia config file; did you run `ia configure`?' >&2
  23. exit 1
  24. fi
  25. exec curl --cookie <(python3 -c 'import configparser, sys; config = configparser.RawConfigParser(); config.read(sys.argv[1]); {print(f".archive.org\tTRUE\t/\tFALSE\t0\t{k}\t{v}") for k, v in config["cookies"].items()}' "${path}") "$@"