view lib/xregcomp.c @ 1046:673fe8f927b0 draft

fix rm to handle "mkdir sub/sub && chmod 007 sub/sub && rm -rf sub". Previous version didn't delete it, but exited without error. Neither was right.
author Rob Landley <>
date Thu, 05 Sep 2013 04:19:37 -0500
parents 786841fdb1e0
line wrap: on
line source

/* Call regcomp() and handle errors.
 * Copyright 2007 Rob Landley <>
 * This is a separate file so environments that haven't got regular expression
 * support can configure this out and avoid a build break.

#include "toys.h"
#include "xregcomp.h"

void xregcomp(regex_t *preg, char *regex, int cflags)
  int rc = regcomp(preg, regex, cflags);

  if (rc) {
    char msg[256];
    regerror(rc, preg, msg, 255);
    error_exit("xregcomp: %s", msg);