Acesso direto ao conteúdo
Logotipo Dicas-L, por Ricardo Burile

Busca

Visite também: Segurança Linux ·  UnderLinux ·  VivaOLinux ·  LinuxSecurity ·  NoticiasLinux ·  BR-Linux ·  SoftwareLivre.org ·  [mais]   
 

Você está aqui: Home  → Arquivo Dicas-L

 

Aprenda inglês de uma vez por todas

Assine a Lista Dicas-L

Receba diariamente por email as dicas
de informática publicadas neste site
Para se descadastrar, clique aqui.

Correção automática do "cd" na bash

Colaboração: Felipe Kellermann

Data de Publicação: 22 de Novembro de 2002

A bash também tem uma outra opção muito interessante, cdspell.

Para habilitar a opção, basta usar o shopt: shopt -s cdspell com a shell em modo interativo. Com esta opção, qualquer erro de digitação, como troca de caracteres, falta de caractere ou caractere adicional, será arrumado pela shell e o comando vai ser executado normalmente.

          /$ cd homr
          bash: cd: homr: No such file or directory
          /$ shopt -s cdspell
          /$ cd homr
          home
          /home$ cd ../hom
          ../home
          /home$

Segundo a man page (man bash)

         shopt [-pqsu] [-o] [optname ...]
                Toggle the values of variables controlling optional shell behavior.  With no options,
                or  with  the -p option, a list of all settable options is displayed, with an indica­
                tion of whether or not each is set.  The -p option causes output to be displayed in a
                form that may be reused as input.  Other options have the following meanings:
                -s     Enable (set) each optname.
                -u     Disable (unset) each optname.
                -q     Suppresses normal output (quiet mode); the return status indicates whether the
                       optname is set or unset.  If multiple optname arguments are given with -q, the
                       return status is zero if all optnames are enabled; non-zero otherwise.
                -o     Restricts  the  values of optname to be those defined for the -o option to the
                       set builtin.

e ainda

                cdspell If set, minor errors in the spelling of a directory component in a cd command
                        will be corrected.  The errors checked for are transposed characters, a miss­
                        ing character, and one character too many.  If a  correction  is  found,  the
                        corrected  file  name  is  printed, and the command proceeds.  This option is
                        only used by interactive shells.

Veja a relação completa dos artigos de Felipe Kellermann

Formato PDF
Newsfeed RSS
Formato para impressão
PDF RSS Imprimir

Referências Adicionais

Referências adicionais sobre os assuntos abordados neste site podem ser encontradas em nossa Bibliografia.

Avalie esta dica

  • Currently 2.98/5
  • 1
  • 2
  • 3
  • 4
  • 5

Avaliação: 3.0 /5 (736 votos)

Opinião dos Leitores

Seja o primeiro a comentar este artigo
*Nome:
Email:
Me notifique sobre novos comentários nessa página
Oculte meu email
*Texto:
 
  Para publicar seu comentário, digite o código contido na imagem acima
 


Powered by Scriptsmill Comments Script
Treinamentos, Consultorias e Soluçoes em TI. Baseados em softwares livres e padrões abertos para ambientes de missão crítica

Submarino.com.br

PDF Explicado