#!/bin/sh # this is the action you want to perform. can either be 'add' or 'remove' ACTION=$1 # email to add or remove EMAIL=$2 check_jq() { command -v jq >/dev/null 2>&1 || { echo "I require jq but it's not installed. Aborting." >&2; exit 1; } } check_params() { if [[ ! $ACTION =~ ^(add|remove)$ ]] then echo "Missing or wrong action" echo "Usage: $0 " exit 1 fi if [ "$EMAIL" = "" ] then echo "Missing email address" echo "Usage: $0 " exit 1 fi } check_jq check_params for i in $( heroku apps --json | jq '.[] | .name' -r ); do heroku access:$1 $2 --app $i done