AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / unix / Perguntas / 534856
Accepted
HappyFace
HappyFace
Asked: 2019-08-11 01:16:39 +0800 CST2019-08-11 01:16:39 +0800 CST 2019-08-11 01:16:39 +0800 CST

zsh: Variável é desativada sem motivo

  • 772

De alguma forma vfica indefinido após a chamada f.

$ zsh -xc 'v=1; f() { local v; v=2 true; }; f; typeset -p v'
+zsh:1> v=1
+zsh:1> f
+f:0> local v
+f:0> v=2 +f:0> true
+zsh:1> typeset -p v
zsh:typeset:1: no such variable: v

Aqui está a essência do meu relatório de reprodução original.

Enviei um e-mail para [email protected] , mas ainda não recebi nenhuma resposta.

zsh variable
  • 1 1 respostas
  • 89 Views

1 respostas

  • Voted
  1. Best Answer
    Stéphane Chazelas
    2019-08-15T13:17:49+08:002019-08-15T13:17:49+08:00

    Isso foi um bug mesmo. Você fez a coisa certa ao denunciá-lo.

    Foi então corrigido por este commit: https://sourceforge.net/p/zsh/code/ci/d946f22a4cd2eed0f3a67881cfa57c805703929c/ que será incluído na próxima versão.

    E aqui está a explicação do zshmantenedor do :

    On Wed, 2019-08-14 at 10:37 +0100, Stephane Chazelas wrote:
    > 2019-08-08 20:38:05 +0430, Aryn Starr:
    > Now, that being said, as discussed on U&L it looks like a bug
    > indeed and a shorter reproducer is:
    > 
    > $ zsh -xc 'v=1; f() { local v; v=2 true; }; f; typeset -p v'
    > +zsh:1> v=1
    > +zsh:1> f
    > +f:0> local v
    > +f:0> v=2 +f:0> true
    > +zsh:1> typeset -p v
    > zsh:typeset:1: no such variable: v
    > 
    > Most likely, that's the "v=2 true" (where "true" is a builtin) that ends up
    > unsetting the "v" from the global scope.
    
    Yes, the saved version of "v" that we restore after the builtin is
    missing the pointer back to the version of v in the enclosing scope.  So
    it's not only not shown as set, it will leak memory.
    
    This simply preserves that pointer in the copy, but this assumes we've
    correctly blocked off the old parameter from being altered inside the
    function scope --- if we haven't that preserved old pointer is going to
    get us into trouble.  However, if we haven't that's already a bug, so
    this shouldn't make things worse.
    
    pws
    

    [patch ignorado]

    • 1

relate perguntas

  • Como incrementar uma variável nomeada dinamicamente em `zsh`

  • Por que não consigo definir uma variável somente leitura chamada path no zsh?

  • Bash ou condição em uma instrução while

  • Como salvar um caminho com ~ em uma variável?

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Possível firmware ausente /lib/firmware/i915/* para o módulo i915

    • 3 respostas
  • Marko Smith

    Falha ao buscar o repositório de backports jessie

    • 4 respostas
  • Marko Smith

    Como exportar uma chave privada GPG e uma chave pública para um arquivo

    • 4 respostas
  • Marko Smith

    Como podemos executar um comando armazenado em uma variável?

    • 5 respostas
  • Marko Smith

    Como configurar o systemd-resolved e o systemd-networkd para usar o servidor DNS local para resolver domínios locais e o servidor DNS remoto para domínios remotos?

    • 3 respostas
  • Marko Smith

    apt-get update error no Kali Linux após a atualização do dist [duplicado]

    • 2 respostas
  • Marko Smith

    Como ver as últimas linhas x do log de serviço systemctl

    • 5 respostas
  • Marko Smith

    Nano - pule para o final do arquivo

    • 8 respostas
  • Marko Smith

    erro grub: você precisa carregar o kernel primeiro

    • 4 respostas
  • Marko Smith

    Como baixar o pacote não instalá-lo com o comando apt-get?

    • 7 respostas
  • Martin Hope
    user12345 Falha ao buscar o repositório de backports jessie 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl Por que a maioria dos exemplos do systemd contém WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky Como exportar uma chave privada GPG e uma chave pública para um arquivo 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll status systemctl mostra: "Estado: degradado" 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim Como podemos executar um comando armazenado em uma variável? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S Por que /dev/null é um arquivo? Por que sua função não é implementada como um programa simples? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 Como ver as últimas linhas x do log de serviço systemctl 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - pule para o final do arquivo 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla Por que verdadeiro e falso são tão grandes? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis Substitua a string em um arquivo de texto enorme (70 GB), uma linha 2017-12-30 06:58:33 +0800 CST

Hot tag

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve