This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Roll X dice with Y sides where $1 = "XdY" or "Y" and "X" is implied to be 1 | |
# Inspired by Tippex x3 | |
function roll() { | |
local re="^([1-9][0-9]*)*([dD]{0,1}([1-9][0-9]*)){0,1}$" | |
if [[ $1 =~ $re && ! $2 ]] ; then | |
# Parse input | |
local dice=1 | |
local sides=0 |