format-url.sh 327 B

1234567891011121314151617181920
  1. #!/usr/bin/env bash
  2. #
  3. # Formats a URL to be clickable from a Buildkite log
  4. #
  5. if [[ $# -eq 0 ]]; then
  6. echo "Usage: $0 url"
  7. exit 1
  8. fi
  9. if [[ -z $BUILDKITE ]]; then
  10. echo "$1"
  11. else
  12. # shellcheck disable=SC2001
  13. URL="$(echo "$1" | sed 's/;/%3b/g')" # Escape ;
  14. printf '\033]1339;url='
  15. echo -n "$URL"
  16. printf '\a\n'
  17. fi