Files
thefuck/thefuck/rules/touch.py
T
Pablo Aguiar cc6d90963e #367: Support BSD style output in touch rule (#830)
On a Mac, also on NetBSD or OpenBSD, `touch` errs differently:

```
$ uname; touch a/b/c
Darwin
touch: a/b/c: No such file or directory
```

That gets matched by the rule but not fixed by it. Thus the regex
pattern is now a bit more tolerant.
2018-07-29 18:18:42 +02:00

15 lines
371 B
Python

import re
from thefuck.shells import shell
from thefuck.utils import for_app
@for_app('touch')
def match(command):
return 'No such file or directory' in command.output
def get_new_command(command):
path = path = re.findall(
r"touch: (?:cannot touch ')?(.+)/.+'?:", command.output)[0]
return shell.and_(u'mkdir -p {}'.format(path), command.script)