[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/09: home: import: Clarify alias parsing code.
From: |
guix-commits |
Subject: |
09/09: home: import: Clarify alias parsing code. |
Date: |
Sun, 20 Mar 2022 14:06:52 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 3748c32b13e5f05211477dd4bb8572e2856558ab
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Mar 20 18:59:47 2022 +0100
home: import: Clarify alias parsing code.
* guix/scripts/home/import.scm (generate-bash-configuration+modules)
[bash-alias->pair]: Return #f on match failure.
[parse-aliases]: Adjust accordingly and use 'match'.
Remove 'filter' call.
---
guix/scripts/home/import.scm | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index f01a98bc55..575fe8f688 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -65,17 +65,19 @@ FILE-NAME with \"-\", and return the basename of it."
(define (bash-alias->pair line)
(match (regexp-exec alias-rx line)
- (#f '())
+ (#f #f)
(matched
`(,(match:substring matched 1) . ,(match:substring matched 2)))))
(define (parse-aliases input)
- (let loop ((line (read-line input))
- (result '()))
- (if (eof-object? line)
- (reverse result)
- (loop (read-line input)
- (cons (bash-alias->pair line) result)))))
+ (let loop ((result '()))
+ (match (read-line input)
+ ((? eof-object?)
+ (reverse result))
+ (line
+ (match (bash-alias->pair line)
+ (#f (loop result))
+ (alias (loop (cons alias result))))))))
(let ((rc (destination-append ".bashrc"))
(profile (destination-append ".bash_profile"))
@@ -85,9 +87,9 @@ FILE-NAME with \"-\", and return the basename of it."
,@(if (file-exists? rc)
`((aliases
',(let* ((port (open-pipe* OPEN_READ "bash" "-i" "-c"
"alias"))
- (alist (parse-aliases port)))
+ (alist (parse-aliases port)))
(close-port port)
- (filter (negate null?) alist))))
+ alist)))
'())
,@(if (file-exists? rc)
`((bashrc
- branch master updated (10d865aa92 -> 3748c32b13), guix-commits, 2022/03/20
- 01/09: home: symlink-manager: Use existing home-directory symbol., guix-commits, 2022/03/20
- 09/09: home: import: Clarify alias parsing code.,
guix-commits <=
- 03/09: home: Explicitly connect home-file and symlink-manager services., guix-commits, 2022/03/20
- 06/09: home: Migrate fountutils and xdg modules to xdg-configuration-files., guix-commits, 2022/03/20
- 08/09: home: import: Properly parse aliases that contain quotes., guix-commits, 2022/03/20
- 04/09: home: Add home-xdg-configuration-files service., guix-commits, 2022/03/20
- 07/09: home: symlink-manager: Respect XDG_CONFIG_HOME during activation., guix-commits, 2022/03/20
- 02/09: home: symlink-manager: Add missing 'done' word in message., guix-commits, 2022/03/20
- 05/09: home: shells: Migrate zsh to xdg-configuration-files., guix-commits, 2022/03/20