Existe um arquivo chamado para dash e sh como shells não de login no diretório / etc?

0

/etc/profile pode ser invocado por sh e dash dentro de um modo de login interativo. Existe algum arquivo no diretório /etc a ser invocado quando eles estão em um modo de não-login interativo?

    
por Bcan 17.09.2018 / 15:43

1 resposta

1

O dash shell (e sh se implementado por dash ) lê /etc/profile quando iniciado como um shell de login. Em seguida, lê ~/.profile . O arquivo ~/.profile pode definir e exportar a variável de ambiente ENV . Essa variável deve conter o caminho para um arquivo originado por shells que não são de login. Isso geralmente é feito por usuário, e não em qualquer arquivo em /etc .

Do manual dash (minha ênfase):

If the environment variable ENV is set on entry to an interactive shell, or is set in the .profile of a login shell, the shell next reads commands from the file named in ENV. Therefore, a user should place commands that are to be executed only at login time in the .profile file, and commands that are executed for every interactive shell inside the ENV file. To set the ENV variable to some file, place the following line in your .profile of your home directory

ENV=$HOME/.shinit; export ENV

substituting for .shinit any filename you wish.

Ao chamar sh ou dash para criar uma sessão shell de logon não interativo de algum outro shell ou processo, apenas certifique-se de que ENV esteja definido para o arquivo de inicialização de shell apropriado. Isso pode ser feito a partir de qualquer shell do tipo Bourne usando

ENV="$HOME/.shinit" sh

ou

ENV="$HOME/.shinit" dash
    
por 17.09.2018 / 16:42

Tags