File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -734,11 +734,20 @@ class SysInfo {
734734 shellIn fo = SysGet ("SHELL" )
735735 // Get shell name only from its path e .g . /usr /bin /fi sh --> fi sh
736736 she ll [:na me ] = JustFileName (shellIn fo )
737- // Execute the shell with the version argument to retrieve the shell version
738- shellVersi on = systemCmd (shellIn fo + " --version" )
737+ // Initialize shellVersion
738+ shellVersi on = "Unknown"
739+ // Skip version check for sh and dash shells since they don 't suppo rt --versi on
740+ if !(she ll [:na me ] = "sh" or she ll [:na me ] = "dash" ) {
741+ // Execute the shell with the version argument to retrieve the shell version
742+ shellVersi on = systemCmd (shellIn fo + " --version" )
743+ }
739744
740745 // Switch statement to determine the shell type and extract its versi on
741746 switch she ll [:na me ] {
747+ ca se "sh"
748+ she ll [:versi on ] = systemCmd ("strings $(which dash) | grep -Eo '[0-9]+\. [0-9]+\. [0-9]+' | head -n1" )
749+ ca se "dash"
750+ she ll [:versi on ] = systemCmd ("strings $(which dash) | grep -Eo '[0-9]+\. [0-9]+\. [0-9]+' | head -n1" )
742751 ca se "bash"
743752 // Find the position of the version number in the shellVersion stri ng
744753 versionP os = substr (shellVersi on , "version " ) + len ("version " )
You can’t perform that action at this time.
0 commit comments