1

I would like to do a check like

if system($(uname -m | sed 's/x86_//;s/i[3-6]86/32/') == 64
    Plug 'valloric/youcompleteme', { 'do': './install.py --all' }
else
    Plug 'valloric/youcompleteme', { 'do': './install.py --clang-complete --system-libclang --omnisharp-completer --gocode-completer --tern-completer --racer-completer' }
endif
2
  • Welcome to this site @Arturo. We value well written questions which show efforts to solve the problem first. Here your expression doesn't have matching brackets and you don't describe which error you get. Please edit your question to address these problems.
    – statox
    May 1, 2017 at 10:10
  • What do you need the check for? If it's to see if 64 Numbers are supported you might use has('num64').
    – Octaviour
    May 1, 2017 at 13:52

1 Answer 1

0

The code you're looking for is the following:

if system('uname -m | grep 64') == 0
    echo '64 bit system'
else
    echo '32 bit system'
endif

Your call to system system($(uname -m | sed 's/x86_//;s/i[3-6]86/32/') doesn't have a matching number of brackets.

Also you don't need to use the $(...) syntax since system() take a string to execute as parameter.

Finally you don't need to use sed, grep is enough to detect the presence of a substring in a string.

4
  • I wonder if has('num64') is the same? May 1, 2017 at 15:18
  • 1
    You could also use uname -p and not have to bother with grep or 'sed` at all. That would make the test if system('uname -p') == "x86_64\n". Note that the output of system() generally includes a terminating newline.
    – garyjohn
    May 1, 2017 at 19:08
  • @garyjohn You're right: I used the grep version to avoid using the new line character in the condition but using one command instead of two is indeed better :)
    – statox
    May 2, 2017 at 7:47
  • @Carpetsmoker I don't know. The doc says 64-bit Number support but I guess you can compile Vim with this flag on a 32 bit system? I'll try to make some test when I have more time.
    – statox
    May 2, 2017 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.