<commit_before>#!/bin/bash
##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
##### Author: <NAME> <<EMAIL>>

#set -xv

err () {
  echo "$1" 1>&2
  exit 1
}

ssh_args=""
while getopts "p:" o; do
  case "$o" in
    p) ssh_args="-p $OPTARG" ;;
  esac
done
shift $(($OPTIND-1))

url="$1"
script="$2"

if [ ! "$url" ]; then
  err "Usage: $0 ssh-url [<local-script>]"
fi

remote_command () {
  ssh $ssh_args "$url" "$1"
}

remote_run () {
  remote_command \
    "rf=\$(mktemp /tmp/remote-run-XXXXXXXX); \
cat > \$rf && chmod +x \$rf && \$rf; rm -f \$rf"
}

if test -n "$script"; then
  cat "$script" | remote_run
else
  remote_run<commit_msg>Improve inline help<commit_after>#!/bin/bash
##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
##### Author: <NAME> <<EMAIL>>

#set -xv

err () {
  echo "$1" 1>&2
  exit 1
}

ssh_args=""
while getopts "p:" o; do
  case "$o" in
    p) ssh_args="-p $OPTARG" ;;
  esac
done
shift $(($OPTIND-1))

url="$1"
script="$2"

if [ ! "$url" ]; then
  err "Usage: $0 <ssh-url> [<local-script>]"
fi

remote_command () {
  ssh $ssh_args "$url" "$1"
}

remote_run () {
  remote_command \
    "rf=\$(mktemp /tmp/remote-run-XXXXXXXX); \
cat > \$rf && chmod +x \$rf && \$rf; rm -f \$rf"
}

if test -n "$script"; then
  cat "$script" | remote_run
else
  remote_run
{'fraction_non_alphanumeric': 0.23529411764705882, 'fraction_numerical': 0.015082956259426848, 'mean_word_length': 3.2396166134185305, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7168767', 'n_tokens_mistral': 591, 'n_tokens_neox': 551, 'n_words': 141}