Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:21:58+00:00 2026-06-02T22:21:58+00:00

I seem to be having issues with some shell scripting (ZSH in particular), where

  • 0

I seem to be having issues with some shell scripting (ZSH in particular), where the shell fails to understand exports with spaces in them. The problem only happens when `runcommand` or $(runcommand) is used.

Test case:

# Works fine:
export test1="a b c"

# Does not work:
$(echo 'export test2="a b c"')

The error is something along the lines of export:4: not valid in this context: c". Adding 1-2 \-escapes before the spaces and/or the quotes might change the error message to export:4: not valid in this context: b\.

Might anyone have insight into what the problem is? Thank you.

(The reason I am doing this is a hack to allow python to set shell variables by dynamically generating code which gets run in .myshellrc; if anyone knows of a more elegant way to do this, that would be quite welcome as a comment. Thank you.) edit: To clarify, I am looking for a way to make the above work, or an alternative way to allow an external script to dictate what to export.

(*sigh*, I hope this isn’t a version-specific issue in 4.3.12… I think this may have worked in the past.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:22:01+00:00Added an answer on June 2, 2026 at 10:22 pm

    The usual way to do this is to use eval as kev has said and pass it the full output of the program in question. The program should then produce valid shell code itself:

    eval "$(your_script.py)"

    And your_script.py would print something like export var1="a b c" (yes, using parenthesis in the output is OK).

    An example of a program using this technique is rbenv. The user has to put eval "$(rbenv init -)" in his shell init file, and rbenv init actually outputs quite a lot of code:

    export PATH="/opt/rbenv/shims:${PATH}"
    source "/opt/rbenv/libexec/../completions/rbenv.zsh"
    rbenv rehash 2>/dev/null
    rbenv() {
      local command="$1"
      if [ "$#" -gt 0 ]; then
        shift
      fi
    
      case "$command" in
      shell)
        eval `rbenv "sh-$command" "$@"`;;
      *)
        command rbenv "$command" "$@";;
      esac
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seem to be having some issues storing the current date in a core data
I seem to be having some issues while attempting to implement logging into my
Evening guys, This may seem like a stupid question but im having some issues
I installed scala 2.8.0 last night and I seem to be having some issues
Just having some issues with building a function using nodeJS. It doesn't seem to
I am having some issues with a parameterized SQL Lite query. I can't seem
Seem to be having some issues with executing jQuery code in the caption class.
I seem to be having a problem with checking for list equality. In my
I seem to be having a problem with my footer growing to 100% width
Okay, I seem to be having a problem. I'm trying to create a twicker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.