aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2014-11-03 14:40:38 -0500
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2014-11-03 14:40:38 -0500
commit6a9d48365f5044b64a6c270760808d17d475ca4b (patch)
treed612b2410fe9af333a79e524f5e5102f9754feed /main.c
parentb4d06df669e1eaf6c98cacb5c5f299bb5324e804 (diff)
parent204bec7af64c61489e37007d45de936482007977 (diff)
downloadegawk-6a9d48365f5044b64a6c270760808d17d475ca4b.tar.gz
egawk-6a9d48365f5044b64a6c270760808d17d475ca4b.tar.bz2
egawk-6a9d48365f5044b64a6c270760808d17d475ca4b.zip
Merge remote-tracking branch 'origin/master' into select
Diffstat (limited to 'main.c')
-rw-r--r--main.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/main.c b/main.c
index 41f10a17..44021e50 100644
--- a/main.c
+++ b/main.c
@@ -212,7 +212,7 @@ main(int argc, char **argv)
/*
* The + on the front tells GNU getopt not to rearrange argv.
*/
- const char *optlist = "+F:f:v:W;bcCd::D::e:E:gh:i:l:L:nNo::Op::MPrStVY";
+ const char *optlist = "+F:f:v:W;bcCd::D::e:E:ghi:l:L:nNo::Op::MPrStVY";
bool stopped_early = false;
int old_optind;
int i;
@@ -1066,18 +1066,23 @@ path_environ(const char *pname, const char *dflt)
NODE *tmp;
tmp = make_string(pname, strlen(pname));
- if (! in_array(ENVIRON_node, tmp)) {
- /*
- * On VMS, environ[] only holds a subset of what getenv() can
- * find, so look AWKPATH up before resorting to default path.
- */
- val = getenv(pname);
- if (val == NULL)
- val = dflt;
- aptr = assoc_lookup(ENVIRON_node, tmp);
+ /*
+ * On VMS, environ[] only holds a subset of what getenv() can
+ * find, so look AWKPATH up before resorting to default path.
+ */
+ val = getenv(pname);
+ if (val == NULL || *val == '\0')
+ val = dflt;
+ aptr = assoc_lookup(ENVIRON_node, tmp);
+ /*
+ * If original value was the empty string, set it to
+ * the default value.
+ */
+ if ((*aptr)->stlen == 0) {
unref(*aptr);
*aptr = make_string(val, strlen(val));
}
+
unref(tmp);
}
@@ -1124,6 +1129,11 @@ load_environ()
/*
* Put AWKPATH and AWKLIBPATH into ENVIRON if not already there.
* This allows querying it from within awk programs.
+ *
+ * October 2014:
+ * If their values are "", override with the default values;
+ * since 2.10 AWKPATH used default value if environment's
+ * value was "".
*/
path_environ("AWKPATH", defpath);
path_environ("AWKLIBPATH", deflibpath);