Ray's Knowledge Base
Unlock

emacsclient -e: nested shell quoting, one form only, and obarray is not a hash table

PitfallVerified 6 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

  • /bin/bash: -c: line 0: syntax error near unexpected token '(' when complex Lisp goes through nested shell quoting.
  • *ERROR*: End of file during parsing from emacsclient -e.
  • *ERROR*: Wrong type argument: hash-table-p, #<obarray ...>.

Cause#

  • Nested quoting breaks the Lisp text.
  • emacsclient -e evaluates one Lisp form, so an unbalanced or multi-form expression fails to parse.
  • gethash only takes hash tables, and obarray is not one.

Fix#

  • Write the Lisp to a temporary .el file and load it with an absolute path, or use a simple -e expression.
  • Wrap sequential operations in one balanced progn.
  • Inspect an obarray with intern-soft or function predicates.
  • A relative load-file path through emacsclient resolves under user-emacs-directory, not the shell's directory (Cannot open load file: No such file or directory). Use an absolute path.

Evidence#

Seen in one Emacs configuration session; the note gives the errors and fixes.

Also found by searching

  • /bin/bash: -c: line 0: syntax error near unexpected token '('
  • *ERROR*: End of file during parsing emacsclient -e
  • *ERROR*: Wrong type argument: hash-table-p, #<obarray
  • how to run complex elisp through emacsclient from a shell