1

I have the following code block in the ~/.bashrc file

function command_not_found_handle {
    for dir in $@; do
        path="${path}${dir}/" 
    done
    if [[ -d ${path} ]]; then
        echo "directory exists and and changing to ${path}"
        cd ${path}
    else
        echo "$@ command not found"
    fi
}

I am attaching the output also Here I am trying to apply cd command for the command which is not exists

out put for the above code block
you can see after trying the unusual command it fired command_not_found_handler as expected but here cd is not worked.
Here mycode git is the command which i have to run.This code checks and make the input to directory path mycode/git and I am trying to pass this to cd but it is not working if it works means the title of the Terminal changes to that directory.
To your clarity I am trying the command manually it changes
Manual Entry of cd
So how can I do that?

Ankanna
  • 141

0 Answers0