.. -*- coding: utf-8 -*- .. role:: sref(numref) .. role:: xref(numref) .. Copyright (C) 2020, Wolfgang Scherer, .. This file is part of Development. .. Permission is granted to copy, distribute and/or modify this document .. under the terms of the GNU Free Documentation License, Version 1.3 .. or any later version published by the Free Software Foundation; .. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. .. A copy of the license is included in the section entitled "GNU .. Free Documentation License". .. inline comments (with du_comment_role) .. role:: rem(comment) .. role:: html(raw) :format: html .. role:: shx(code) :language: sh .. rst-class:: narrow xmedium xlarge xhuge xultra ################################################## :rem:`|||:sec:|||`\ Shell Wildcards and Filenames ################################################## .. >>CODD See `the components of a doctoral dissertation and their order `_ .. >>CODD Dedication .. >>CODD Epigraph .. >>CODD Abstract .. compound:: .. \|:here:| .. >>CODD Introduction ================================================== :rem:`|||:sec:|||`\ Glob pattern expansion ================================================== Glob patterns are always expanded. No restrictions are applied. See also :program:`bin/check-glob-pattens.sh`. .. code-block:: sh mkdir -p glob-check cd glob-check || exit 1 touch echo touch file1 touch file2 touch file3 The command: .. code-block:: sh ls -l shows the available files: .. code-block:: text insgesamt 0 -rw-rw-r-- 1 da da 0 Okt 23 13:03 echo -rw-rw-r-- 1 da da 0 Okt 23 13:03 file1 -rw-rw-r-- 1 da da 0 Okt 23 13:03 file2 -rw-rw-r-- 1 da da 0 Okt 23 13:03 file3 Command execution of: .. code-block:: sh echo * results in: .. code-block:: text echo file1 file2 file3 Expanding the wildcard: .. code-block:: sh * results in: .. code-block:: sh echo file1 file2 file3 which is executed and results in: .. code-block:: text file1 file2 file3 ================================================== :rem:`|||:sec:|||`\ Non-matching glob patterns ================================================== If a glob pattern does not match, the glob pattern is used unexpanded: .. code-block:: sh for _file in not_here* do pecho "${_file}" done Output: .. code-block:: text not_here* file1 file2 file3 If non-existent file should be ignored, an explicit test is necessary: .. code-block:: sh for _file in not_here* file* do test -r "${_file}" || continue pecho "${_file}" done Output: .. code-block:: text file1 file2 file3 Using ls(1) is another possibliity, (**but it does not work if filenames contain whitespace**): .. code-block:: sh for _file in $( ls -1 not_here* file* 2>/dev/null ) do pecho "${_file}" done Output: .. code-block:: text file1 file2 file3 ============================================================== :rem:`|||:sec:|||`\ Directory separator and illegal characters ============================================================== The directory separator is always illegal. Which character is used for directory separation depends on the filesystem. +---------------------+-------------+-------------+----------+----------+------------+ | OS | Win 95/98 | Win 2000+ | Mac OS 9 | Mac OS X | Unix/Linux | +---------------------+-------------+-------------+----------+----------+------------+ | File System | FAT 32 | NTFS | HFS + | HFS+/UFS | UFS | +=====================+=============+=============+==========+==========+============+ | Max Char. | 255 | 256 | 31 | 255 | 255 | +---------------------+-------------+-------------+----------+----------+------------+ | Max Path. | 260 | 260 | | | | +---------------------+-------------+-------------+----------+----------+------------+ | Restricted | "\*/\\:<>?| | "\*/\\:<>?| | : | /: | / | +---------------------+-------------+-------------+----------+----------+------------+ | Directory Separator | \\ | \\ | : | : | / | +---------------------+-------------+-------------+----------+----------+------------+ | Case Sensitivity | NO | NO | NO | NO | YES | +---------------------+-------------+-------------+----------+----------+------------+ Soure: `File Systems - HFS+, UFS, FAT32 and NTFS, Operating Systems, Maximum Characters Allowed Comparison`_ .. _`File Systems - HFS+, UFS, FAT32 and NTFS, Operating Systems, Maximum Characters Allowed Comparison`: https://www.comentum.com/File-Systems-HFS-FAT-UFS.html -------------------------------------------------------------------------------------------- :rem:`||:sec:||`\ 7-bit ASCII, printable, without directory separator and illegal characters -------------------------------------------------------------------------------------------- 7 bit can encode the characters from 0 - 127. Table columns are: character, decimal, octal, hexadecimal, PS name, ASCII name. Illegal characters (for any file system) are marked with the name ILLEGAL. Printable characters starts after SPACE: .. code-block:: text [ ] : 32 : 040 : x20 . and end before DEL: .. code-block:: text [^?] : 127 : 177 : x7F : : DEL . Printable characters are therefore .. code-block:: text [ ] : 32 : 040 : x20 . [!] : 33 : 041 : x21 . ["] : 34 : 042 : x22 : : ILLEGAL . [#] : 35 : 043 : x23 . [$] : 36 : 044 : x24 . [%] : 37 : 045 : x25 . [&] : 38 : 046 : x26 . ['] : 39 : 047 : x27 . [(] : 40 : 050 : x28 . [)] : 41 : 051 : x29 . [*] : 42 : 052 : x2A : : ILLEGAL . [+] : 43 : 053 : x2B . [,] : 44 : 054 : x2C . [-] : 45 : 055 : x2D . [.] : 46 : 056 : x2E . [/] : 47 : 057 : x2F : : ILLEGAL . [0] : 48 : 060 : x30 . [1] : 49 : 061 : x31 . [2] : 50 : 062 : x32 . [3] : 51 : 063 : x33 . [4] : 52 : 064 : x34 . [5] : 53 : 065 : x35 . [6] : 54 : 066 : x36 . [7] : 55 : 067 : x37 . [8] : 56 : 070 : x38 . [9] : 57 : 071 : x39 . [:] : 58 : 072 : x3A : : ILLEGAL . [;] : 59 : 073 : x3B . [<] : 60 : 074 : x3C : : ILLEGAL . [=] : 61 : 075 : x3D . [>] : 62 : 076 : x3E : : ILLEGAL . [?] : 63 : 077 : x3F : : ILLEGAL . [@] : 64 : 100 : x40 . [A] : 65 : 101 : x41 . [B] : 66 : 102 : x42 . [C] : 67 : 103 : x43 . [D] : 68 : 104 : x44 . [E] : 69 : 105 : x45 . [F] : 70 : 106 : x46 . [G] : 71 : 107 : x47 . [H] : 72 : 110 : x48 . [I] : 73 : 111 : x49 . [J] : 74 : 112 : x4A . [K] : 75 : 113 : x4B . [L] : 76 : 114 : x4C . [M] : 77 : 115 : x4D . [N] : 78 : 116 : x4E . [O] : 79 : 117 : x4F . [P] : 80 : 120 : x50 . [Q] : 81 : 121 : x51 . [R] : 82 : 122 : x52 . [S] : 83 : 123 : x53 . [T] : 84 : 124 : x54 . [U] : 85 : 125 : x55 . [V] : 86 : 126 : x56 . [W] : 87 : 127 : x57 . [X] : 88 : 130 : x58 . [Y] : 89 : 131 : x59 . [Z] : 90 : 132 : x5A . [[] : 91 : 133 : x5B . [\] : 92 : 134 : x5C : : ILLEGAL . []] : 93 : 135 : x5D . [^] : 94 : 136 : x5E . [_] : 95 : 137 : x5F . [`] : 96 : 140 : x60 . [a] : 97 : 141 : x61 . [b] : 98 : 142 : x62 . [c] : 99 : 143 : x63 . [d] : 100 : 144 : x64 . [e] : 101 : 145 : x65 . [f] : 102 : 146 : x66 . [g] : 103 : 147 : x67 . [h] : 104 : 150 : x68 . [i] : 105 : 151 : x69 . [j] : 106 : 152 : x6A . [k] : 107 : 153 : x6B . [l] : 108 : 154 : x6C . [m] : 109 : 155 : x6D . [n] : 110 : 156 : x6E . [o] : 111 : 157 : x6F . [p] : 112 : 160 : x70 . [q] : 113 : 161 : x71 . [r] : 114 : 162 : x72 . [s] : 115 : 163 : x73 . [t] : 116 : 164 : x74 . [u] : 117 : 165 : x75 . [v] : 118 : 166 : x76 . [w] : 119 : 167 : x77 . [x] : 120 : 170 : x78 . [y] : 121 : 171 : x79 . [z] : 122 : 172 : x7A . [{] : 123 : 173 : x7B . [|] : 124 : 174 : x7C : : ILLEGAL . [}] : 125 : 175 : x7D . [~] : 126 : 176 : x7E . .. >>CODD Chapter .. >>CODD Conclusion .. >>CODD Appendix A .. \|:here:| .. >>CODD Notes .. ================================================== .. :rem:`|||:sec:|||`\ Footnotes .. ================================================== :html:`
` .. \[#] .. include:: doc_defs.inc .. include:: abbrev_defs.inc .. include:: doc_defs_combined.inc .. .. \||<-snap->|| doc_standalone .. include:: doc/doc_defs_secret.inc .. \||<-snap->|| doc_standalone .. \||<-snap->|| not_doc_standalone .. include:: doc_defs_secret.inc .. \||<-snap->|| not_doc_standalone .. _`Wolfgang Scherer`: wolfgang.scherer@gmx.de