@@ -250,6 +250,108 @@ mod unix {
250250 Ok ( ( ) )
251251 }
252252
253+ #[ test]
254+ fn inline_script_with_sh_shebang ( ) {
255+ let context = TestContext :: new ( ) ;
256+ context. init_project ( ) ;
257+ context. write_pre_commit_config ( indoc:: indoc! { r#"
258+ repos:
259+ - repo: local
260+ hooks:
261+ - id: inline
262+ name: inline
263+ language: script
264+ entry: |
265+ #!/usr/bin/env sh
266+ echo "hello from sh"
267+ pass_filenames: false
268+ verbose: true
269+ "# } ) ;
270+ context. git_add ( "." ) ;
271+
272+ cmd_snapshot ! ( context. filters( ) , context. run( ) , @r"
273+ success: true
274+ exit_code: 0
275+ ----- stdout -----
276+ inline...................................................................Passed
277+ - hook id: inline
278+ - duration: [TIME]
279+
280+ hello from sh
281+
282+ ----- stderr -----
283+ " ) ;
284+ }
285+
286+ #[ test]
287+ fn inline_script_no_shebang_crlf_line_endings ( ) {
288+ let context = TestContext :: new ( ) ;
289+ context. init_project ( ) ;
290+
291+ // Ensure CRLF is accepted (common on Windows checkouts) even on unix.
292+ let config = indoc:: indoc! { r#"
293+ repos:
294+ - repo: local
295+ hooks:
296+ - id: inline
297+ name: inline
298+ language: script
299+ entry: "echo one\r\necho two\r\n"
300+ pass_filenames: false
301+ verbose: true
302+ "# }
303+ . replace ( '\n' , "\r \n " ) ;
304+
305+ context. write_pre_commit_config ( & config) ;
306+ context. git_add ( "." ) ;
307+
308+ cmd_snapshot ! ( context. filters( ) , context. run( ) , @r"
309+ success: true
310+ exit_code: 0
311+ ----- stdout -----
312+ inline...................................................................Passed
313+ - hook id: inline
314+ - duration: [TIME]
315+
316+ one
317+ two
318+
319+ ----- stderr -----
320+ " ) ;
321+ }
322+
323+ #[ test]
324+ fn inline_script_no_shebang_stops_on_error ( ) {
325+ let context = TestContext :: new ( ) ;
326+ context. init_project ( ) ;
327+ context. write_pre_commit_config ( indoc:: indoc! { r#"
328+ repos:
329+ - repo: local
330+ hooks:
331+ - id: inline
332+ name: inline
333+ language: script
334+ entry: |
335+ false
336+ echo "should not print"
337+ pass_filenames: false
338+ verbose: true
339+ "# } ) ;
340+ context. git_add ( "." ) ;
341+
342+ cmd_snapshot ! ( context. filters( ) , context. run( ) , @r"
343+ success: false
344+ exit_code: 1
345+ ----- stdout -----
346+ inline...................................................................Failed
347+ - hook id: inline
348+ - duration: [TIME]
349+ - exit code: 1
350+
351+ ----- stderr -----
352+ " ) ;
353+ }
354+
253355 #[ test]
254356 fn multiline_entry_still_script_path ( ) -> Result < ( ) > {
255357 let context = TestContext :: new ( ) ;
0 commit comments