Skip to content

Commit

Permalink
Fix shellcheck issues in add-classpath-entries.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Schmid committed May 25, 2020
1 parent ff9aac5 commit 908d3ab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
13 changes: 8 additions & 5 deletions tomcat/add-classpath-entries.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/sh

set -e
mkdir -p "{{.libDir}}"
while IFS=: read -d: -r path; do
printf "Linking $path to '{{.libDir}}/$(basename $path)'\n"
ln -s "$path" "{{.libDir}}/$(basename $path)"
done <<< "${CLASSPATH}"
(
IFS=:
for path in $(printf '%s' "$CLASSPATH"); do
printf "Linking %s to '{{.libDir}}/$(basename "$path")'\n" "$path"
ln -s "$path" "{{.libDir}}/$(basename "$path")"
done
)
2 changes: 1 addition & 1 deletion tomcat/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (b Base) ContributeLogging(layer libcnb.Layer) error {
func (b Base) ContributeClasspathEntries(layer libcnb.Layer) error {
b.Logger.Bodyf("Adding profile-script 'add-classpath-entries.sh'")

libDir := fmt.Sprintf("%s/lib", layer.Path)
libDir := filepath.Join(layer.Path, "lib")
s, err := sherpa.TemplateFile("/add-classpath-entries.sh", map[string]interface{}{"libDir": libDir})
if err != nil {
return fmt.Errorf("unable to load add-classpath-entries.sh\n%w", err)
Expand Down
13 changes: 8 additions & 5 deletions tomcat/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,15 @@ export JAVA_OPTS="${JAVA_OPTS} -Daccess.logging.enabled=true"
`))
libDir := filepath.Join(layer.Path, "lib")
Expect(layer.Profile["add-classpath-entries.sh"]).To(Equal(fmt.Sprintf(`#!/bin/sh
set -e
mkdir -p "%[1]s"
while IFS=: read -d: -r path; do
printf "Linking $path to '%[1]v/$(basename $path)'\n"
ln -s "$path" "%[1]s/$(basename $path)"
done <<< "${CLASSPATH}"
(
IFS=:
for path in $(printf '%%s' "$CLASSPATH"); do
printf "Linking %%s to '%[1]s/$(basename "$path")'\n" "$path"
ln -s "$path" "%[1]s/$(basename "$path")"
done
)
`, libDir)))
Expect(filepath.Join(layer.Path, "lib", "stub-tomcat-lifecycle-support.jar")).To(BeARegularFile())
Expect(filepath.Join(layer.Path, "bin", "stub-tomcat-logging-support.jar")).To(BeARegularFile())
Expand Down
2 changes: 1 addition & 1 deletion tomcat/statik/statik.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 908d3ab

Please sign in to comment.