diff --git a/cmd/shfmt/testdata/script/walk.txtar b/cmd/shfmt/testdata/script/walk.txtar index 2969b9c3..16edcfc8 100644 --- a/cmd/shfmt/testdata/script/walk.txtar +++ b/cmd/shfmt/testdata/script/walk.txtar @@ -183,9 +183,9 @@ foo #!/bin/envsh foo --- skip/ext.zsh +-- skip/ext.zsh -- foo --- skip/shebang-zsh +-- skip/shebang-zsh -- #!/bin/zsh foo -- skip/.git/ext.sh -- diff --git a/fileutil/file.go b/fileutil/file.go index d69a2b9b..822d21b2 100644 --- a/fileutil/file.go +++ b/fileutil/file.go @@ -13,8 +13,8 @@ import ( ) var ( - shebangRe = regexp.MustCompile(`^#!\s?/(usr/)?bin/(env\s+)?(sh|bash|mksh|bats|zsh)(\s|$)`) - extRe = regexp.MustCompile(`\.(sh|bash|mksh|bats|zsh)$`) + shebangRe = regexp.MustCompile(`^#!\s?/(usr/)?bin/(env\s+)?(sh|bash|mksh|bats)(\s|$)`) + extRe = regexp.MustCompile(`\.(sh|bash|mksh|bats)$`) ) // TODO: consider removing HasShebang in favor of Shebang in v4