Opened 8 years ago

Closed 6 years ago

#15275 closed defect (fixed)

Make "sage -c 'attach(...); print 3'" work right

Reported by: jhpalmieri Owned by:
Priority: minor Milestone: sage-6.5
Component: scripts Keywords:
Cc: Merged in:
Authors: André Apitzsch Reviewers: Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: fdc586f (Commits, GitHub, GitLab) Commit: fdc586f44213fd7f4af050690ec7371b9a8f2146
Dependencies: Stopgaps:

Status badges

Description

This was first reported on stackoverflow.

While running Sage:

sage: attach("file.sage"); print 3

works, but from the shell:

$ sage -c "attach('file.sage'); print 3"

fails. It actually tries to execute the command

sage "/path/to/'file.sage'; print Integer(2)"

and so it tries to read everything between the first and last quotes as the file name, thus producing the error

python: can't open file '/path/to/'file.sage'; print Integer(2)': [Errno 2] No such file or directory

This is because the script sage-eval tries to do something clever when the command to be executed starts with attach or load, but it is assuming that the rest of the command consists entirely of the file name.

Change History (9)

comment:1 Changed 8 years ago by jhpalmieri

  • Priority changed from major to minor

comment:2 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:3 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:4 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 6 years ago by aapitzsch

Problem was introduced by #508. Since I couldn't find an answer why ./sage -c "attach file.sage" was supposed to work, I suggest to revert the changes made in #508.

comment:6 Changed 6 years ago by jdemeyer

+1 to undo the "something clever"

comment:7 Changed 6 years ago by aapitzsch

  • Authors set to André Apitzsch
  • Branch set to u/aapitzsch/ticket/15275
  • Commit set to fdc586f44213fd7f4af050690ec7371b9a8f2146
  • Status changed from new to needs_review

comment:8 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-6.4 to sage-6.5
  • Reviewers set to Jeroen Demeyer
  • Status changed from needs_review to positive_review

comment:9 Changed 6 years ago by vbraun

  • Branch changed from u/aapitzsch/ticket/15275 to fdc586f44213fd7f4af050690ec7371b9a8f2146
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.