aboutsummaryrefslogtreecommitdiff
path: root/src/os/shell.c
blob: b2248541b9f5949b9d4e9dcad2e092e0563616a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdbool.h>

#include "os/shell.h"
#include "types.h"
#include "ascii.h"


void shell_skip_word(char_u **ptr)
{
  char_u *p = *ptr;
  bool inquote = false;

  // Move `p` to the end of shell word by advancing the pointer it while it's
  // inside a quote or it's a non-whitespace character
  while (*p && (inquote || (*p != ' ' && *p != TAB))) {
    if (*p == '"')
      // Found a quote character, switch the `inquote` flag
      inquote = !inquote;
    ++p;
  }

  *ptr = p;
}