in reply to Re^3: How to replace envs in path?
in thread How to replace envs in path?
It contains different use cases. If you take a look at them, you can see that:set playground="${HOME}/playground" set file1=${playground}'/fi$le1' set file2=${playground}'/file2$' set file3=${playground}'/f$i$l$e$3$' set file4=${playground}'/fi\$le4' mkdir -p ${playground} touch ${file1} touch ${file2} touch ${file3} touch ${file4}
The two most interesting ones are file1 and file4. File1 does not escape the special symbol but File4 does escape it. I even can go further and create something like:ls -la $HOME/playground total 8 drwxr-s--- 2 root root 4096 May 22 06:26 . drwxr-s--- 7 root root 4096 May 22 06:26 .. -rw-r----- 1 root root 0 May 22 06:26 f$i$l$e$3$ -rw-r----- 1 root root 0 May 22 06:26 fi$le1 -rw-r----- 1 root root 0 May 22 06:26 fi\$le4 -rw-r----- 1 root root 0 May 22 06:26 file2$
All of them are considered valid paths. My utility gets those paths and should check if there is a defined env in that path and if so, replace it. So the current algorithm is:> touch $HOME/playground/fi\\\\\$le5 > ls -la $HOME/playground/ total 8 drwxr-s--- 2 root root 4096 May 22 22:57 . drwxr-s--- 7 root root 4096 May 22 06:26 .. -rw-r----- 1 root root 0 May 22 06:26 f$i$l$e$3$ -rw-r----- 1 root root 0 May 22 06:26 fi$le1 -rw-r----- 1 root root 0 May 22 06:26 fi\$le4 -rw-r----- 1 root root 0 May 22 22:57 fi\\$le5 -rw-r----- 1 root root 0 May 22 06:26 file2$
And then just remove every occurence of UNSPECIFIED. But I see two problems with it:drwxr-s--- 2 root root 4096 May 22 22:57 . drwxr-s--- 7 root root 4096 May 22 06:26 .. -rw-r----- 1 root root 0 May 22 06:26 fUNSPECIFIED$iUNSPECIFIED$lUN +SPECIFIED$eUNSPECIFIED$3UNSPECIFIED$ -rw-r----- 1 root root 0 May 22 06:26 fiUNSPECIFIED$le1 -rw-r----- 1 root root 0 May 22 06:26 fi\UNSPECIFIED$le4 -rw-r----- 1 root root 0 May 22 22:57 fi\\UNSPECIFIED$le5 -rw-r----- 1 root root 0 May 22 06:26 file2UNSPECIFIED$
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How to replace envs in path?
by BillKSmith (Monsignor) on May 23, 2022 at 22:35 UTC | |
by hv (Prior) on May 24, 2022 at 00:08 UTC | |
by BillKSmith (Monsignor) on May 24, 2022 at 13:15 UTC |