From c2df2d2a586964491fa16164d125b55eaa607322 Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Mon, 24 Jun 2024 12:10:58 +0200 Subject: [PATCH] Get crab command complete fucntion from crab-bash-completion.sh --- crab-build.file | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crab-build.file b/crab-build.file index 6dd41d6b718..65c33d2b795 100644 --- a/crab-build.file +++ b/crab-build.file @@ -43,14 +43,17 @@ for pkg in %{crabserver_packages} ; do fi done -#complete command in crab-bash-completion.sh should match '^\s*complete\s+-F\s+.*\s_UseCrab\s.*\scrab\s*$' -COMPLETE_CMD=$(grep '^\s*complete\s\s*-F\s' %{i}/etc/crab-bash-completion.sh | grep '\s_UseCrab\s' | grep '\scrab\s*$') +#complete command in crab-bash-completion.sh should match '^\s*complete\s+-F\s+.*\s\s.*\scrab\s*$' +COMPLETE_CMD=$(grep '^\s*complete\s\s*-F\s' %{i}/etc/crab-bash-completion.sh | grep '\scrab\s*$') if [ "${COMPLETE_CMD}" != "" ] ; then + CRAB_FUNC=$(echo "${COMPLETE_CMD}" | sed 's|^.*\s-F\s\s*||;s|\s.*||') sed -i -e 's|^\s*complete\s\s*-F\s.*$|@COMPLETE_CMD@|' %{i}/etc/crab-bash-completion.sh - if [ "%{crab_type}" != "prod" ] ; then + if [ "%{crab_type}" = "prod" ] ; then + COMPLETE_CMD=$(echo "${COMPLETE_CMD}" | sed "s/\scrab\s*$/ crab-%{crab_type}\\\n${COMPLETE_CMD}/") + else COMPLETE_CMD=$(echo "${COMPLETE_CMD}" | sed 's/\scrab\s*$/ crab-%{crab_type}/') fi - sed -i -e "s/@COMPLETE_CMD@/${COMPLETE_CMD}/;s|_UseCrab|_UseCrab_%{crab_type}|" %{i}/etc/crab-bash-completion.sh + sed -i -e "s/@COMPLETE_CMD@/${COMPLETE_CMD}/;s|${CRAB_FUNC}|${CRAB_FUNC}_%{crab_type}|g" %{i}/etc/crab-bash-completion.sh else echo "ERROR: Unable to fix crab use function _UseCrab" exit 1