File tree Expand file tree Collapse file tree 4 files changed +26
-19
lines changed Expand file tree Collapse file tree 4 files changed +26
-19
lines changed Original file line number Diff line number Diff line change 11# Bash Language Server
22
3+ ## 3.2.1
4+
5+ - Fix shebang parser that ignores some bash files https://github.com/bash-lsp/bash-language-server/pull/560
6+
37## 3.2.0
48
59- Dependency upgrades
Original file line number Diff line number Diff line change 33 "description" : " A language server for Bash" ,
44 "author" : " Mads Hartmann" ,
55 "license" : " MIT" ,
6- "version" : " 3.2.0 " ,
6+ "version" : " 3.2.1 " ,
77 "publisher" : " mads-hartmann" ,
88 "main" : " ./out/server.js" ,
99 "typings" : " ./out/server.d.ts" ,
Original file line number Diff line number Diff line change @@ -9,23 +9,18 @@ describe('hasBashShebang', () => {
99 expect ( hasBashShebang ( `#!/usr/bin/env python2.7\n# set -x` ) ) . toBe ( false )
1010 } )
1111
12- it ( 'returns true for "#!/bin/sh -"' , ( ) => {
13- expect ( hasBashShebang ( '#!/bin/sh -' ) ) . toBe ( true )
14- expect ( hasBashShebang ( '#!/bin/sh - ' ) ) . toBe ( true )
12+ it ( 'returns false for "#!/usr/bin/pwsh"' , ( ) => {
13+ expect ( hasBashShebang ( '#!/usr/bin/pwsh' ) ) . toBe ( false )
1514 } )
1615
17- it ( 'returns true for "#!/usr/bin/env bash"' , ( ) => {
18- expect ( hasBashShebang ( '#!/usr/bin/env bash' ) ) . toBe ( true )
19- expect ( hasBashShebang ( '#!/usr/bin/env bash ' ) ) . toBe ( true )
20- } )
21-
22- it ( 'returns true for "#!/bin/sh"' , ( ) => {
23- expect ( hasBashShebang ( '#!/bin/sh' ) ) . toBe ( true )
24- expect ( hasBashShebang ( '#!/bin/sh ' ) ) . toBe ( true )
25- } )
26-
27- it ( 'returns true for "#!/bin/bash"' , ( ) => {
28- expect ( hasBashShebang ( '#!/bin/bash' ) ) . toBe ( true )
29- expect ( hasBashShebang ( '#!/bin/bash ' ) ) . toBe ( true )
16+ test . each ( [
17+ [ '#!/bin/sh -' ] ,
18+ [ '#!/usr/bin/env bash' ] ,
19+ [ '#!/bin/sh' ] ,
20+ [ '#!/bin/bash' ] ,
21+ [ '#!/bin/bash -u' ] ,
22+ ] ) ( 'returns true for %p' , ( command ) => {
23+ expect ( hasBashShebang ( command ) ) . toBe ( true )
24+ expect ( hasBashShebang ( `${ command } ` ) ) . toBe ( true )
3025 } )
3126} )
Original file line number Diff line number Diff line change @@ -6,11 +6,19 @@ export function getShebang(fileContent: string): string | null {
66 return null
77 }
88
9- return match [ 1 ] . replace ( '-' , '' ) . trim ( )
9+ return match [ 1 ]
1010}
1111
12+ /**
13+ * Check if the given shebang is a bash shebang.
14+ */
1215export function isBashShebang ( shebang : string ) : boolean {
13- return shebang . endsWith ( 'bash' ) || shebang . endsWith ( 'sh' )
16+ return (
17+ shebang . startsWith ( '/bin/bash' ) ||
18+ shebang . startsWith ( '/bin/sh' ) ||
19+ shebang . startsWith ( '/usr/bin/env bash' ) ||
20+ shebang . startsWith ( '/usr/bin/env sh' )
21+ )
1422}
1523
1624export function hasBashShebang ( fileContent : string ) : boolean {
You can’t perform that action at this time.
0 commit comments