Skip to content

Instantly share code, notes, and snippets.

@konsolebox
Created May 16, 2026 14:58
Show Gist options
  • Select an option

  • Save konsolebox/9ef66990af880a185ea5491e5f8906b7 to your computer and use it in GitHub Desktop.

Select an option

Save konsolebox/9ef66990af880a185ea5491e5f8906b7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Selects Ruby interpreter based on the name of the called symbolic link linked to it.
# This script was composed with significant help from Google AI.
cmd=${0##*/}
if [[ ${cmd} =~ ^([a-zA-Z_-]+)([0-9][0-9])$ ]]; then
base_cmd="${BASH_REMATCH[1]}"
ruby_ver="${BASH_REMATCH[2]}"
exec "/usr/bin/ruby${ruby_ver}" "/usr/bin/${base_cmd}" "$@"
else
echo "Error: '${cmd}' is not a valid versioned symlink target." >&2
echo "Usage: Create a symlink named <utility><version> (e.g., irb33) pointing to this script." >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment