Setting environment variable with leading digit in bash

bash, environment-variables, linux, shell

Solution

You can also bypass the bash interpreter and define the variable directly with the bash internal functions:

$ gdb --batch-silent -ex "attach $$"                              \
    -ex 'set bind_variable("64bit", "1", 0)'                      \
    -ex 'set *(int*)(find_variable("64bit")+sizeof(char*)*5) = 1' \
    -ex 'set array_needs_making = 1'

$ env | grep 64
64bit=1

Problem

I need to set an environment variable called "64bit" (i.e. with a leading digit) in bash. However, bash variable names disallow a variable with a leading digit. I know a way to set it when invoking bash: ``` env 64bit=1 /usr/bin/bash ``` However, I'm looking for a way to change it in the currently running shell i.e. not by starting a new shell. I also know that csh allows variables to start with a digit, but I need to use bash. Is there any way to achieve this?

Original source