Bash tiene problemas con cmdline nft cmd vs script

Bash tiene problemas con cmdline nft cmd vs script

menta de linux.uname -rrendimientos5.15.0-56.consulta-dpkg -l bashrendimientos5.1.6ubuntu1.
Mi script muestra este resultado problemático cuandoscript bash -xinvocado:

attrib =' '\''{type nat hook prerouting  priority mangle+10;}'\'' '

Pero desde la línea de comando:

sudo nft create chain inet firewalld mangle_PREROUTING '{ type nat hook prerouting priority mangle + 10 ;}'

Funciona bien.
Este script replica el árbol nft de Fedora.

 x=$(sudo nft -a list tables)   
 if [[ $x != '' ]]; then  
     sudo nft flush table inet firewalld  
      sudo nft delete table inet firewalld  
 fi  
 sudo nft create table inet firewalld  
 for stage in mangle net filter;do  
     for step in _PREROUTING _OUTPUT _INPUT _IN_workstation; do
      meat=${step/_/}   
       priority=${stage/_/}   
       a=${step/_[a-zA-Z]+/_}   
       b=${stage/_[a-zA-Z]+/_}   
       if [[ $stage =="__"]]; then   
            type="nat"   
       else
            type="filter"   
       fi.   
       hook=${meat,,}   #translate to all lowercase.  
       attrib=" '{ type "$type" hook "$hook" priority "$priority"+10;}'"   

      
    if[[ $a$b == "__" ]]; then   
        cmd=" insert rule inet firewalld $stage$step" ;   
         sudo nft $cmd  
     else  
         cmd=" create chain inet firewalld $stage$step $attrib";   
        sudo nft $cmd  
    fi  
     done  
  done  

Respuesta1

La respuesta fue eliminar las comillas simples alrededor de las llaves. Intenté esto porque pensé que el script de shell (y sudo) estaban haciendo una bifurcación/exec, para nft, sin interpretación de shell.

información relacionada