From 1ea82b792a3a6cc83d92ec5c78453eaf87df4b36 Mon Sep 17 00:00:00 2001 From: Alistair Grant Date: Mon, 21 Oct 2024 17:40:51 +0200 Subject: [PATCH] GtShellScriptProcess: don't assume bash location --- .../GtShellScriptProcess.class.st | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Lepiter-Snippet-Shell/GtShellScriptProcess.class.st b/src/Lepiter-Snippet-Shell/GtShellScriptProcess.class.st index 86da7d3f..a0b8372c 100644 --- a/src/Lepiter-Snippet-Shell/GtShellScriptProcess.class.st +++ b/src/Lepiter-Snippet-Shell/GtShellScriptProcess.class.st @@ -19,9 +19,38 @@ Class { 'bindings', 'onSuccess' ], + #classVars : [ + 'BashExecutable' + ], #category : #'Lepiter-Snippet-Shell' } +{ #category : #accessing } +GtShellScriptProcess class >> bashExecutable [ + + ^ BashExecutable ifNil: [ BashExecutable := self findBashExecutable fullName ] +] + +{ #category : #private } +GtShellScriptProcess class >> findBashExecutable [ + "Answer the path to the specified executable. + Run this is a shell as some platforms, e.g. Mac, don't set up the same environment for processes started from the file explorer." + + ^ GtOsSystemInfo current findExecutable: 'bash'. +] + +{ #category : #initialization } +GtShellScriptProcess class >> initialize [ + + SessionManager default registerSystemClassNamed: self name. +] + +{ #category : #initialization } +GtShellScriptProcess class >> startUp: resuming [ + + resuming ifTrue: [ BashExecutable := nil ] +] + { #category : #private } GtShellScriptProcess >> announce: announcement [ self announcer announce: announcement @@ -224,7 +253,7 @@ GtShellScriptProcess >> newShellScriptBuilder [ arg: '-c' ] ifFalse: [ GtExternalProcessBuilder new - command: '/bin/bash'; + command: self class bashExecutable; arg: '-c' ] ]