Встроенные клавиши со стрелками для редактирования строки во время чтения zsh

Eche un vistazo a la página del manual para el comando file:

$ man file

...

file tests each argument in an attempt to classify it. There are three sets of tests, performed in this order: filesystem tests, magic tests, and language tests. The first test that succeeds causes the file type to be printed.

Es la tercera prueba(pruebas de idioma)que realiza fileque clasifica este archivo como un archivo C++.

Once file has determined the character set used in a text-type file, it will attempt to determine in what language the file is written. The language tests look for particular strings (cf. #include ) that can appear anywhere in the first few blocks of a file. For example, the keyword.br indicates that the file is most likely a troff(1) input file, just as the keyword struct indicates a C program. These tests are less reliable than the previous two groups, so they are performed last. The language test routines also test for some miscellany (such as tar(1) archives).

Los archivos C #se asemejan más a los archivos C++, por lo que file"supone" que el archivo.cs es un archivo C++.

Ejemplo

$ more blah.cs
// A Hello World! program in C#.
using System;
namespace HelloWorld
{
    class Hello
    {
        static void Main()
        {
            Console.WriteLine("Hello World!");

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}

Comprobación confile:

$ file blah.cs
blah.cs: ASCII C++ program text
1
23.03.2019, 03:08
1 ответ

Основываясь на комментарии, ссылающемся на этот ответ , я узнал о vared. Вот то, что я использовал, и оно отлично работает:

#!/usr/bin/env zsh
IFS="$(printf "\n\t")"
query=
vared -p "${1-query}: " query 
echo "${query}"
2
28.04.2021, 23:35

Теги

Похожие вопросы