ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 29 Jan 2015 11:26:45 -0600Sagetex : hyphen in filename forbidden ?http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/I want to cross-compile (pdflatex + sage + pdflatex) a TeX file : it's ok with the filename "a-b.tex", but not for a-n.tex, where i get the error message
CRITICAL:root:unknown notebook: None
Error, notebook must be one of default, ipython, sagenb but got None
It seems that the problem is with the "-n" part of a-n.tex
it's a bug or a feature ?
lg
macosX 10.10.1 + sage 6.4.1
Wed, 28 Jan 2015 07:43:55 -0600http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/Comment by slelievre for <p>I want to cross-compile (pdflatex + sage + pdflatex) a TeX file : it's ok with the filename "a-b.tex", but not for a-n.tex, where i get the error message</p>
<p>CRITICAL:root:unknown notebook: None
Error, notebook must be one of default, ipython, sagenb but got None</p>
<p>It seems that the problem is with the "-n" part of a-n.tex</p>
<p>it's a bug or a feature ?
lg</p>
<p>macosX 10.10.1 + sage 6.4.1</p>
http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/?comment=25627#post-id-25627I confirm that: I copied sagetex's example file "example.tex" with the name "a-n.tex", ran "pdflatex a-n.tex", then "sage a-n.sagetex.sage" and Sage gives the same error message.Wed, 28 Jan 2015 09:57:43 -0600http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/?comment=25627#post-id-25627Comment by kcrisman for <p>I want to cross-compile (pdflatex + sage + pdflatex) a TeX file : it's ok with the filename "a-b.tex", but not for a-n.tex, where i get the error message</p>
<p>CRITICAL:root:unknown notebook: None
Error, notebook must be one of default, ipython, sagenb but got None</p>
<p>It seems that the problem is with the "-n" part of a-n.tex</p>
<p>it's a bug or a feature ?
lg</p>
<p>macosX 10.10.1 + sage 6.4.1</p>
http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/?comment=25625#post-id-25625That is really interesting; `-n` is what launches the notebook. What are the names of the particular *Sage* files generated? That is what Sage runs on.Wed, 28 Jan 2015 09:22:15 -0600http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/?comment=25625#post-id-25625Answer by tmonteil for <p>I want to cross-compile (pdflatex + sage + pdflatex) a TeX file : it's ok with the filename "a-b.tex", but not for a-n.tex, where i get the error message</p>
<p>CRITICAL:root:unknown notebook: None
Error, notebook must be one of default, ipython, sagenb but got None</p>
<p>It seems that the problem is with the "-n" part of a-n.tex</p>
<p>it's a bug or a feature ?
lg</p>
<p>macosX 10.10.1 + sage 6.4.1</p>
http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/?answer=25628#post-id-25628This is a bug, thanks for reporting. On the file `src/bin/sage`, there is a condition:
if [[ "$1" =~ "--notebook="* || "$1" =~ "-n="* || "$1" =~ "-notebook="* ]]; then
sage-cleaner &>/dev/null &
exec sage-notebook "$@"
fi
The problem is that it is accepted if `-n` is part of the variable `$1`, not only a prefix, as you can check with:
$ A='aze-naze'
$ if [[ "$A" =~ "-n="* ]] ; then echo hop ; fi
hop
A better solution would be to add a `^` to specify the beginning of the string and use `.*` instead of `*`:
$ A='aze-n=aze'
$ if [[ $A =~ ^-n=.* ]] ; then echo hop ; fi
$ A='-naze'
$ if [[ $A =~ ^-n=.* ]] ; then echo hop ; fi
$ A='-n=aze'
$ if [[ $A =~ ^-n=.* ]] ; then echo hop ; fi
hop
It is reported as [trac ticket 17685](http://trac.sagemath.org/ticket/17685).
Wed, 28 Jan 2015 10:04:29 -0600http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/?answer=25628#post-id-25628Comment by kcrisman for <p>This is a bug, thanks for reporting. On the file <code>src/bin/sage</code>, there is a condition:</p>
<pre><code>if [[ "$1" =~ "--notebook="* || "$1" =~ "-n="* || "$1" =~ "-notebook="* ]]; then
sage-cleaner &>/dev/null &
exec sage-notebook "$@"
fi
</code></pre>
<p>The problem is that it is accepted if <code>-n</code> is part of the variable <code>$1</code>, not only a prefix, as you can check with:</p>
<pre><code>$ A='aze-naze'
$ if [[ "$A" =~ "-n="* ]] ; then echo hop ; fi
hop
</code></pre>
<p>A better solution would be to add a <code>^</code> to specify the beginning of the string and use <code>.*</code> instead of <code>*</code>:</p>
<pre><code>$ A='aze-n=aze'
$ if [[ $A =~ ^-n=.* ]] ; then echo hop ; fi
$ A='-naze'
$ if [[ $A =~ ^-n=.* ]] ; then echo hop ; fi
$ A='-n=aze'
$ if [[ $A =~ ^-n=.* ]] ; then echo hop ; fi
hop
</code></pre>
<p>It is reported as <a href="http://trac.sagemath.org/ticket/17685">trac ticket 17685</a>.</p>
http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/?comment=25638#post-id-25638And the fix will be in Sage 6.5!Thu, 29 Jan 2015 11:26:45 -0600http://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/?comment=25638#post-id-25638