O resultado do eco * e do eco. *

1

Normalmente, o resultado do comando echo * deve ser "Qualquer arquivo no diretório atual". Deve incluir o dotfile?

Da mesma forma, o resultado de ls * deve incluir o dotfile?

    
por user43312 20.07.2013 / 12:10

1 resposta

5

Na seção Expansão do nome de arquivo da referência de bash GNU:

When a pattern is used for filename expansion, the character ‘.’ at the start of a filename or immediately following a slash must be matched explicitly, unless the shell option dotglob is set. When matching a file name, the slash character must always be matched explicitly. In other cases, the ‘.’ character is not treated specially.

Isso é documentado (e esperado) comportamento em todos os shells POSIX, veja Padrões usados para expansão de nome de arquivo :

If a filename begins with a period ( '.' ), the period shall be explicitly matched by using a period as the first character of the pattern or immediately following a slash character. The leading period shall not be matched by:

  • The asterisk or question-mark special characters

  • A bracket expression containing a non-matching list, such as "[!a]", a range expression, such as "[%-0]", or a character class expression, such as "[[:punct:]]"

It is unspecified whether an explicit period in a bracket expression matching list, such as "[.abc]", can match a leading period in a filename.

    
por 20.07.2013 / 12:38