Question: I am trying to pass a parameter to a function with `Smarty`. Like this:

```
$('#buttonClose').click(function(){
    var name = document.getElementById('nameSpan').value;
    {$person->addName(name)}
});

```

but it pass the value "name" instead of the real value of the variable `name`. 

How can I do that to get the real value of the variable `name` in the function `addName`?

Thanks in advance!

Answer: 
Using `gnu-awk` you can do this easily:

```
awk -v FPAT='"[^"]*"|[^[:blank:]]+' -v OFS='\t' '{$1=$1} 1' file
foo bar "foobar baz qux"
foo "bar foobar baz"    qux
"foo   bar foobar"  baz qux

```
I would use the following command:

```
awk '{$1=$1}1' OFS='\t' FPAT='"[^"]+"|[^ ]+'

```

I define two kind of possible field trough the `FPAT` variable:

* a string enclosed in double quotes `"[^"]+"`
* a sequence of non whitespace characters `[^ ]+`

Because the enclosed string comes first, it has a higher precedence.

The results can be better visualized on SO when piping to `cat -A`:

```
awk '{$1=$1}1' OFS='\t' FPAT='"[^"]+"|[^ ]+' a.txt | cat -A

```

Output:

```none
foo^Ibar^I"foobar baz qux"$
foo^I"bar foobar baz"^Iqux$
"foo   bar foobar"^Ibaz^Iqux$

```