user2741831
user2741831

Reputation: 2408

How do I to get the exit code of a command through an external external terminal

I'm using this code for a cpp project generator (/newt/cpp contains a main.cpp and a CMakeLists.txt) The Generic Method is supposed to be called silently when pressing F5 and is just supposed to compile and start the programm, but only if the compilation succeeds. But the problem is that urxvt doesn't inherit the exit code of the command it is executing, So I have no way of telling whether the command succeeded or not. So here my question: How can I run a command in an external shell and figure out the exit code?

function SetupCPP()
    !cp -a ~/.config/nvim/src/newt/cpp/. .
    e main.cpp
    function! GenericRun()
        call system("urxvt -e sh -c \"cmake . \"") 
        if v:shell_error != 0
            return
        endif

        call system("urxvt -e sh -c \"make . || read && false\"") 
        if v:shell_error != 0
            return
        endif

        call system("urxvt -e './main'")

    endfunction
endfunction

Upvotes: 0

Views: 46

Answers (0)

Related Questions