fix: 100-sed-fooRbar.
This commit is contained in:
parent
9115b9fbb6
commit
632295fa18
|
@ -29,6 +29,7 @@
|
|||
#:use-module (gash config)
|
||||
#:use-module (gash guix-utils)
|
||||
#:use-module (gash shell-utils)
|
||||
#:use-module (gash util)
|
||||
|
||||
#:export (
|
||||
sed
|
||||
|
@ -114,6 +115,9 @@ Usage: sed [OPTION]... [SCRIPT] [FILE]...
|
|||
(cond ((string-prefix? "s" o)
|
||||
(let* ((command (substring o 1))
|
||||
(string (substring command 1))
|
||||
(string (string-replace-string string "\\n" "\n"))
|
||||
(string (string-replace-string string "\\r" "\r"))
|
||||
(string (string-replace-string string "\\t" "\t"))
|
||||
(separator (string-ref command 0)))
|
||||
(receive (search replace modifier-string)
|
||||
(apply values (string-split string separator))
|
||||
|
|
|
@ -24,17 +24,11 @@
|
|||
#:use-module (ice-9 getopt-long)
|
||||
#:use-module (ice-9 rdelim)
|
||||
#:use-module (gash config)
|
||||
#:use-module (gash util)
|
||||
#:export (
|
||||
tr
|
||||
))
|
||||
|
||||
(define (string-replace-string string from to)
|
||||
(cond ((string-contains string from)
|
||||
=>
|
||||
(lambda (i)
|
||||
(string-replace string to i (+ i (string-length from)))))
|
||||
(else string)))
|
||||
|
||||
(define (tr . args)
|
||||
(let* ((option-spec
|
||||
'((delete (single-char #\d))
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
wrap-command
|
||||
char->string
|
||||
string->string-list
|
||||
string-replace-string
|
||||
))
|
||||
|
||||
(define (disjoin . predicates)
|
||||
|
@ -42,3 +43,10 @@
|
|||
|
||||
(define (char->string c)
|
||||
(make-string 1 c))
|
||||
|
||||
(define (string-replace-string string from to)
|
||||
(cond ((string-contains string from)
|
||||
=>
|
||||
(lambda (i)
|
||||
(string-replace string to i (+ i (string-length from)))))
|
||||
(else string)))
|
||||
|
|
Loading…
Reference in New Issue