src/main/java/de/unixwork/uwproj/Util.java

changeset 41
75ee588d5d9e
parent 40
b42bfc9e9983
child 64
00586d892855
--- a/src/main/java/de/unixwork/uwproj/Util.java	Wed Sep 06 22:55:42 2023 +0200
+++ b/src/main/java/de/unixwork/uwproj/Util.java	Sun Sep 10 12:52:10 2023 +0200
@@ -16,7 +16,8 @@
         for (int i = 0; i < nodes.getLength(); i++) {
             var node = nodes.item(i);
             if (node.getNodeType() == Node.TEXT_NODE) {
-                return node.getTextContent();
+                final var v = node.getNodeValue();
+                return v == null ? "" : v;
             }
         }
         return "";
@@ -29,4 +30,18 @@
     public static boolean isNotNullOrBlank(String s) {
         return s != null && !s.isBlank();
     }
+
+    /**
+     * Creates an identifier from the given string that can be used as an identifier in a POSIX shell script.
+     * <p>
+     * If the given string does not contain any character that is illegal in a POSIX shell variable or function name,
+     * the string is returned unmodified.
+     *
+     * @param s the input string
+     * @return the sanitized string
+     */
+    public static String shId(String s) {
+        // TODO: implement
+        return s;
+    }
 }

mercurial