More details on G`MIC substitution rules? Also, rules for filenames.

On the substition rules, there is lack of commonly used names for $_os, and $_host.I would like to know all of them though in my case for now, $_os is what matters. What I am going to do is to make a G’MIC script that will output acceptable filenames (More on that below). Maybe that should be part of output command though.

On $_os:

  1. Windows → windows

On $_host:

  1. cli → cli
  2. krita → krita
  3. gimp → gimp
  4. Paint.NET → paintdotnet
  5. 8bf → plugin8bf

~~ @PDN_GMIC: Please confirm on 8bf. ~~

So, on $_os, I do not know what would be the remaining output. Mac → mac? Linux → linux?


As I have mentioned there are rules for file names, I have found these.

On Windows: Naming Files, Paths, and Namespaces - Win32 apps | Microsoft Docs

On Linux: https://www.cyberciti.biz/faq/linuxunix-rules-for-naming-file-and-directory-names/

On Mac: Illegal Filename Characters on Windows vs Mac OS | Black Belt Review


From what I can gather, the universal rules are:

1.There can be no characters on the following list:

  • <
  • >
  • :
  • >
  • "
  • /
  • \
  • |
  • ?
  • *
  • &

2.Filename cannot be ASCII NULL.
3.There cannot be consecutive period. A filename cannot begin with a dot either.
4.None of the reserved names are permitted

  • CON
  • PRN
  • AUX
  • NUL
  • COM1
  • COM2
  • COM3
  • COM4
  • COM5
  • COM6
  • COM7
  • COM8
  • COM9
  • LPT1
  • LPT2
  • LPT3
  • LPT4
  • LPT5
  • LPT6
  • LPT7
  • LPT8
  • LPT9
  1. Maximum number of character is 31. Could be outdated. 255 as maximum.

Note: | can be replaced with l or 1.

Edit: Thanks PDN_GMIC for specifying hostname.

Filenames often begin with a dot.

There cannot be consecutive period.

In Windows and bash (Cygwin bash on Windows), double dots are permitted. But I think using this would be unwise.

I think I will settle for a command that output fixed filename. Just pushed it to G’MIC. It follows all the universal rule except for string length < 32.

But I think using this would be unwise.

Of course, I think they should be automatically replaced with underscore instead. There’s also the mistakening of double extensions as well.

The 8bf host name is plugin8bf. In C and C++ the preprocessor definition names cannot start with a number.

Not a dot by itself, the . and .. file names are reserved as shorthand for the current and parent directories respectively. A file name can start with a dot, e.g. .temp .
From the MSDN page you linked to:

Use a period as a directory component in a path to represent the current directory, for example “.\temp.txt”.

Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory, for example “..\temp.txt”.

Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name.

The 1-31 reference is describing that ASCII control characters are illegal in a file name.
In ASCII the 0-31 range is used for control characters, e.g. the \r (Carriage Return) and \n (Line Feed) values used as line terminators in a text file. https://www.ascii-code.com/ has a table listing the ASCII control characters.

On most versions of Windows the total path length cannot exceed 260 characters, see Maximum Path Length Limitation for details.