[pwgen] rewrite in shell script
1 files changed, 9 insertions(+), 7 deletions(-)

M bin/pwgen
M bin/pwgen +9 -7
@@ 1,9 1,11 @@ 
-#!/usr/bin/env ruby
+#!/bin/sh
 
-require 'securerandom'
+set -e
+set -u
 
-length = ARGV[0].to_i
-length = 12 if length <= 0
-5.times do |n|
-  puts "#{n}: #{SecureRandom.urlsafe_base64(length).slice(0, length)}"
-end
+_length="${1:-12}"
+
+for i in 1 2 3 4 5; do
+  printf "%s: " "$i"
+  openssl rand -base64 "$_length" | tr '/+' '-_' | cut -c "1-$_length"
+done