From 5e94db47ac610924e071aec72697c5d86d2cfd6c Mon Sep 17 00:00:00 2001 From: Wildan M Date: Mon, 10 Aug 2026 15:03:03 +0700 Subject: [PATCH] Improve open-recipe script --- scripts/open-recipe.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/scripts/open-recipe.sh b/scripts/open-recipe.sh index 3a693893d..451249d91 100755 --- a/scripts/open-recipe.sh +++ b/scripts/open-recipe.sh @@ -1,9 +1,30 @@ #!/usr/bin/env bash -# This script open the recipe configuration files with chosen EDITOR env, or chosen by "open" cli. +set -e + +# This script open the recipe configuration files with chosen EDITOR env, or chosen by "xdg-open" cli. # This script must be launched outside podman -EDITOR=${EDITOR:-open} +if [ -z "$1" ] +then + echo "Open a file into a recipe." + echo "" + echo "Usage: [EDITOR=program] $0 [file]" + echo " [EDITOR=program]: The EDITOR envar to set which app to open, default to 'EDITOR=xdg-open'" + echo " : The recipe name, cannot be multiple" + echo " [file]: The filename to open, default to 'recipe.toml'" + echo "" + echo "example:" + echo " $0 kernel" + echo " EDITOR=nano $0 kernel" + echo " EDITOR=nvim $0 kernel source" + exit 1 +fi -$EDITOR $(make find.$1)/recipe.toml +EDITOR=${EDITOR:-xdg-open} +FILE=${2:-recipe.toml} + +RECIPE_PATH=$(make find.$1) +RECIPE_PATH=${RECIPE_PATH//$'\r'/} +"$EDITOR" "$RECIPE_PATH/$FILE"