pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk/scripts Added a code snippet that demonstrates how ...
details: https://anonhg.NetBSD.org/pkgsrc/rev/e996619559d1
branches: trunk
changeset: 498524:e996619559d1
user: rillig <rillig%pkgsrc.org@localhost>
date: Wed Aug 24 21:51:10 2005 +0000
description:
Added a code snippet that demonstrates how to set the $@ array to the
lines printed by a shell command. In contrast to the read(1) shell
utility, there are no problems when the output contains backslashes.
diffstat:
mk/scripts/shell-lib | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diffs (24 lines):
diff -r 5e8ded604877 -r e996619559d1 mk/scripts/shell-lib
--- a/mk/scripts/shell-lib Wed Aug 24 19:50:07 2005 +0000
+++ b/mk/scripts/shell-lib Wed Aug 24 21:51:10 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shell-lib,v 1.2 2004/09/21 15:14:08 jlam Exp $
+# $NetBSD: shell-lib,v 1.3 2005/08/24 21:51:10 rillig Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -383,3 +383,14 @@
return 1
fi
}
+
+######################################################################
+# $setargs_from_cmd
+# Run $cmd and initialize the $@ array with the lines from that
+# command.
+# usage:
+# cmd="echo *"; eval "${setargs_from_cmd}"
+# for i in "$@"; do echo "($i)"; done
+######################################################################
+setargs_from_cmd='saved_IFS="${IFS}"; IFS="
+"; set args `eval "${cmd}"`; IFS="${saved_IFS}"; shift'
Home |
Main Index |
Thread Index |
Old Index