summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/heasoft/heasoft-6.29_xspec-12.12.0a.patch
blob: 9cb627589c5030bd9efd5de72fa949d361965a1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--- a/Xspec/src/XSUser/UserInterface/execscript.cxx	2021-02-19 10:47:02.000000000 -0600
+++ b/Xspec/src/XSUser/UserInterface/execscript.cxx	2022-02-16 10:35:18.765454040 -0600
@@ -366,19 +366,23 @@
          XSparse::collateByWhitespace(lineArgs, buffer);
          string procName;
          string scriptName;
-         
-         if (lineArgs[0] == "cd")
+         // Careful, if line contained whitespace and nothing but
+         //  whitespace, lineArgs vector will be empty.
+         if (lineArgs.size())
          {
-            // If no second argument, assume cd into home directory.
-            string cdPath = (lineArgs.size() < 2) ? string("~/") : lineArgs[1];
-            appendPathToScript(cdPath, currPathToScript);
-         }         
-         else if (findProcFromLineArgs(lineArgs, procName))
-            userProcs.insert(procName);
-         else if (isCallToScript(lineArgs, scriptName))
-         {
-            // Recursive call
-            status = findNestedUserProcs(scriptName, userProcs, currPathToScript);
+            if (lineArgs[0] == "cd")
+            {
+               // If no second argument, assume cd into home directory.
+               string cdPath = (lineArgs.size() < 2) ? string("~/") : lineArgs[1];
+               appendPathToScript(cdPath, currPathToScript);
+            }         
+            else if (findProcFromLineArgs(lineArgs, procName))
+               userProcs.insert(procName);
+            else if (isCallToScript(lineArgs, scriptName))
+            {
+               // Recursive call
+               status = findNestedUserProcs(scriptName, userProcs, currPathToScript);
+            }
          }
       }
    }