Project

General

Profile

« Previous | Next » 

Revision 9314

lib/sh/util.sh: str2varname(): use bash's internal ${var//glob/repl} syntax, which supports character classes ([a-z], etc.), instead of sed (which is slower because it's an external command and uses regexps)

View differences:

lib/sh/util.sh
8 8

  
9 9
realpath() { readlink -f -- "$1"; }
10 10

  
11
str2varname() { builtin command sed 's/[^a-zA-Z0-9_]/_/g' <<<"$1"; }
11
str2varname() { echo "${1//[^a-zA-Z0-9_]/_}"; }
12 12

  
13 13
include_guard_var() { str2varname "$(realpath "$1")"; }
14 14

  

Also available in: Unified diff