Skip to content

Instantly share code, notes, and snippets.

@aleofreddi
Last active April 9, 2020 08:50
Show Gist options
  • Save aleofreddi/3d3da3162dd9e2fcb4dae6b8cabde87c to your computer and use it in GitHub Desktop.
Save aleofreddi/3d3da3162dd9e2fcb4dae6b8cabde87c to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -p
#
# Perl implementation of envsubst for systems where it does not exist (eg. macOSX).
#
# Wed Apr 18 08:03:05 CEST 2018, Andrea Leofreddi
#
$_ =~ s/\Q${$1||$2}/$ENV{$1?$2:$4}/ while $_ =~ /(\$\{([^}]+)})|(\$(\w+))/g;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment