-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shell: added Is_Command_* functions suite
Since the Is_Command_* functions suite was accidentally ported, it's better to commit it in. Hence, let's do this. This patch adds Is_Command_* functions suite into Shell/ directory. Co-authored-by: Shuralyov, Jean <[email protected]> Co-authored-by: Galyna, Cory <[email protected]> Co-authored-by: (Holloway) Chew, Kean Ho <[email protected]> Signed-off-by: (Holloway) Chew, Kean Ho <[email protected]>
- Loading branch information
1 parent
540d996
commit d1bf69f
Showing
40 changed files
with
2,536 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Is-Command-Alias-OS { | ||
param ( | ||
[string]$___command | ||
) | ||
|
||
|
||
# validate input | ||
if ($___command -eq "") { | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} | ||
|
||
|
||
# execute | ||
$___process = Get-Command $___command ` | ||
-CommandType Alias ` | ||
-ErrorAction SilentlyContinue | ||
if ($___process) { | ||
return ${env:HestiaKERNEL_ERROR_OK} | ||
} | ||
|
||
|
||
# report status | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" | ||
|
||
|
||
|
||
|
||
HestiaKERNEL_Is_Command_Alias_OS() { | ||
#___command="$1" | ||
|
||
|
||
# validate input | ||
if [ "$1" = "" ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING | ||
return $HestiaKERNEL_ERROR_DATA_MISSING | ||
fi | ||
|
||
|
||
# execute | ||
___ret="$(2>&1 type "$1")" | ||
if [ ! "${___ret##*alias}" = "$___ret" ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_OK | ||
return $HestiaKERNEL_ERROR_OK | ||
fi | ||
|
||
|
||
# report status | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING | ||
return $HestiaKERNEL_ERROR_DATA_MISSING | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Is-Command-Available-OS { | ||
param ( | ||
[string]$___command | ||
) | ||
|
||
|
||
# validate input | ||
if ($___command -eq "") { | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} | ||
|
||
|
||
# execute | ||
$___process = Get-Command $___command -ErrorAction SilentlyContinue | ||
if ($___process) { | ||
return ${env:HestiaKERNEL_ERROR_OK} | ||
} | ||
|
||
|
||
# report status | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" | ||
|
||
|
||
|
||
|
||
HestiaKERNEL_Is_Command_Available_OS() { | ||
#___command="$1" | ||
|
||
|
||
# validate input | ||
if [ "$1" = "" ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING | ||
return $HestiaKERNEL_ERROR_DATA_MISSING | ||
fi | ||
|
||
|
||
# execute | ||
___ret="$(2>&1 type "$1")" | ||
if [ "${___ret##*not found}" = "$___ret" ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_OK | ||
return $HestiaKERNEL_ERROR_OK | ||
fi | ||
|
||
|
||
# report status | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING | ||
return $HestiaKERNEL_ERROR_DATA_MISSING | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Is-Command-Builtin-OS { | ||
param ( | ||
[string]$___command | ||
) | ||
|
||
|
||
# validate input | ||
if ($___command -eq "") { | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} | ||
|
||
|
||
# execute | ||
$___process = Get-Command $___command ` | ||
-CommandType Cmdlet ` | ||
-ErrorAction SilentlyContinue | ||
if ($___process) { | ||
return ${env:HestiaKERNEL_ERROR_OK} | ||
} | ||
|
||
|
||
# report status | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" | ||
|
||
|
||
|
||
|
||
HestiaKERNEL_Is_Command_Builtin_OS() { | ||
#___command="$1" | ||
|
||
|
||
# validate input | ||
if [ "$1" = "" ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING | ||
return $HestiaKERNEL_ERROR_DATA_MISSING | ||
fi | ||
|
||
|
||
# execute | ||
___ret="$(2>&1 type "$1")" | ||
if [ ! "${___ret##*shell builtin}" = "$___ret" ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_OK | ||
return $HestiaKERNEL_ERROR_OK | ||
fi | ||
|
||
|
||
# report status | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING | ||
return $HestiaKERNEL_ERROR_DATA_MISSING | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Is-Command-External-OS { | ||
param ( | ||
[string]$___command | ||
) | ||
|
||
|
||
# validate input | ||
if ($___command -eq "") { | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} | ||
|
||
|
||
# execute | ||
$___process = Get-Command $___command ` | ||
-CommandType Application, ExternalScript, Script ` | ||
-ErrorAction SilentlyContinue | ||
if ($___process) { | ||
return ${env:HestiaKERNEL_ERROR_OK} | ||
} | ||
|
||
|
||
# report status | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Alias.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Available.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Builtin.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Function.sh" | ||
|
||
|
||
|
||
|
||
HestiaKERNEL_Is_Command_External_OS() { | ||
#___command="$1" | ||
|
||
|
||
# validate input | ||
if [ "$1" = "" ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING | ||
return $HestiaKERNEL_ERROR_DATA_MISSING | ||
fi | ||
|
||
|
||
# execute | ||
if [ "$(HestiaKERNEL_Is_Command_Alias_OS "$1")" -ne $HestiaKERNEL_ERROR_OK ] && | ||
[ "$(HestiaKERNEL_Is_Command_Builtin_OS "$1")" -ne $HestiaKERNEL_ERROR_OK ] && | ||
[ "$(HestiaKERNEL_Is_Command_Function_OS "$1")" -ne $HestiaKERNEL_ERROR_OK ] && | ||
[ "$(HestiaKERNEL_Is_Command_Available_OS "$1")" -eq $HestiaKERNEL_ERROR_OK ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_OK | ||
return $HestiaKERNEL_ERROR_OK | ||
fi | ||
|
||
|
||
# report status | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING | ||
return $HestiaKERNEL_ERROR_DATA_MISSING | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Is-Command-Function-OS { | ||
param ( | ||
[string]$___command | ||
) | ||
|
||
|
||
# validate input | ||
if ($___command -eq "") { | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} | ||
|
||
|
||
# execute | ||
$___process = Get-Command $___command ` | ||
-CommandType Function ` | ||
-ErrorAction SilentlyContinue | ||
if ($___process) { | ||
return ${env:HestiaKERNEL_ERROR_OK} | ||
} | ||
|
||
|
||
# report status | ||
return ${env:HestiaKERNEL_ERROR_DATA_MISSING} | ||
} |
Oops, something went wrong.