Skip to content

Commit 044c425

Browse files
committed
Add LICENSE to install.zsh
also also simplify pattern and replacement for a gsub call.
1 parent 5243b4f commit 044c425

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
srcfiles := src/install.zsh.erb $(wildcard src/*/*)
1+
srcfiles := src/install.zsh.erb $(wildcard src/*/*) LICENSE
22

33
install.zsh: $(srcfiles)
44
erb $< >| $@

install.zsh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
# AUTOMATICALLY GENERATED FILE. EDIT ONLY THE SOURCE FILES AND THEN COMPILE.
22
# DO NOT DIRECTLY EDIT THIS FILE!
33

4+
# MIT License
5+
#
6+
# Copyright (c) 2019-2020 Eric Nielsen and contributors
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy
9+
# of this software and associated documentation files (the "Software"), to deal
10+
# in the Software without restriction, including without limitation the rights
11+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
# copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included in all
16+
# copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
# SOFTWARE.
25+
426
if [[ -z ${ZSH_VERSION} ]]; then
527
print -u2 -P '%F{red}x You must use zsh to run install.zsh'
628
return 1

src/install.zsh.erb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Zim
2323
def render_template(filename)
2424
render(filename)
2525
.gsub(/\\/, "\\\\\\\\")
26-
.gsub(/(\$[^']|"|`)/, "\\\\\\1")
26+
.gsub(/(?=\$[^']|"|`)/, "\\\\")
2727
.gsub(/\\\${ZDOTDIR:-\\\${HOME}}\/\.zim\b/, "${ZIM_HOME_STR}")
2828
end
2929

@@ -32,9 +32,14 @@ class Zim
3232
"ZTEMPLATES[#{File.basename(filename)}]=\"#{render_template(filename)}\""
3333
}.join("\n")
3434
end
35+
36+
def render_commented(filename)
37+
render(filename).gsub(/^(?=.)/, "# ").gsub(/^$/, "#")
38+
end
3539
end
3640
zim = Zim.new
3741
%># AUTOMATICALLY GENERATED FILE. EDIT ONLY THE SOURCE FILES AND THEN COMPILE.
3842
# DO NOT DIRECTLY EDIT THIS FILE!
3943

44+
<%= zim.render_commented("LICENSE") %>
4045
<%= zim.render_all("src/steps/*.erb") %>

0 commit comments

Comments
 (0)