ruby - Simple Regex test in shell for commit message -


i'm new shell , need port simple commit-msg hook written in ruby, problem on regex test, can help?

this code in ruby:

#!/usr/bin/env ruby message_file = argv[0] message = file.read(message_file)  $regex = /\[([a-z]+)-\d+\](.)*/  if !$regex.match(message)   puts "[error] please use following pattern: '[abc-123] lorem ipsum'"   exit 1 end 

in sh script be

#!/bin/sh if echo $1 | egrep -qv '\[([a-z]+)-\d+\](.)*';   echo "[error] please use following pattern: '[abc-123] lorem ipsum'"   exit 1; fi 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -