I'm trying to test if ANDROID_NDK_ROOT is set in an Autoconf script. The relevant stanza is shown below. According to How can I check an environment variable? on the Autoconf mailing list, I can use:
if test "${var+set}" = set; then
echo "variable \$var is set to: $var"
fi
The variable is not set, but my AC_MSG_ERROR is not being executed.
$ printenv | grep ANDROID_NDK_ROOT
$
Instead, the test is producing the following error:
./configure: line 20616: syntax error near unexpected token `('
./configure: line 20616: ` $as_echo_n "(cached) " >&6'
(There's another reply in the thread but it seems to be just a comment and does not answer the question).
How do I test if an environmental variable is set in Autoconf?
Here is the stanza I am trying to execute in configure.ac:
# if test "$IS_ANDROID_OS" != "0"; then
if true; then
if test "${ANDROID_NDK_ROOT+set}" != set; then
AC_MSG_ERROR([ANDROID_NDK_ROOT is not set. Please set ANDROID_NDK_ROOT])
fi
THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h"
AC_CHECK_FILE([$THIS_FILE],
[cp "$THIS_FILE" "$ac_srcdir"],
AC_MSG_RESULT([cpu-features.h does not exist in ANDROID_NDK_ROOT, skipping])
)
THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c"
AC_CHECK_FILE([$THIS_FILE],
[cp "$THIS_FILE" "$ac_srcdir"],
AC_MSG_RESULT([cpu-features.c does not exist in ANDROID_NDK_ROOT, skipping])
)
fi
Here is the chunk of configure from cat -n:
20610
20611 THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c"
20612 as_ac_File=`$as_echo "ac_cv_file_$THIS_FILE" | $as_tr_sh`
20613 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $THIS_FILE" >&5
20614 $as_echo_n "checking for $THIS_FILE... " >&6; }
20615 if eval \${$as_ac_File+:} false; then :
20616 $as_echo_n "(cached) " >&6
20617 else
20618 test "$cross_compiling" = yes &&
20619 as_fn_error $? "cannot check for file existence when cross compiling""$LINENO" 5
20620 if test -r "$THIS_FILE"; then
20621 eval "$as_ac_File=yes"
20622 else
20623 eval "$as_ac_File=no"
20624 fi
I came across this old question and figured I'd share a solution I ended up using when I needed to check multiple variables were set (in this sanitized example, VAR1 thru VAR4):
m4_foreach_w([my_var],[VAR1 VAR2 VAR3 VAR4],[
AS_VAR_IF(myvar, [], AC_MSG_ERROR([Missing required variable: myvar!]))
AC_SUBST(myvar)dnl Export variable to Makefile as well
AC_ARG_VAR(myvar, [])dnl if this variable changes, re-run configuration
])
There's nothing wrong with your shell syntax for testing whether a variable is set, and it works fine with Autoconf.
The problem appears to arise from failing to quote the third arguments to the AC_CHECK_FILE() macros. You should always quote (with square brackets) each argument to each macro, especially when that argument is or contains a macro call itself. I can reproduce a syntax error in configure by wrapping the example code you provided between an AC_INIT and an AC_OUTPUT, but it goes away with proper quoting. Specifically, here:
THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h"
AC_CHECK_FILE([$THIS_FILE],
[cp "$THIS_FILE" "$ac_srcdir"],
[AC_MSG_RESULT([cpu-features.h does not exist in ANDROID_NDK_ROOT, skipping])]
)
THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c"
AC_CHECK_FILE([$THIS_FILE],
[cp "$THIS_FILE" "$ac_srcdir"],
[AC_MSG_RESULT([cpu-features.c does not exist in ANDROID_NDK_ROOT, skipping])]
)
Failing to quote the argument results in it being expanded too many times, and the resulting output indeed is not syntactically valid shell code.
Related
I'm trying to execute a script to create a role in postgres
$PSQL_CLIENT "host=$servername user=$DB_POSTGRES_USERNAME dbname=postgres password='$DB_PASSWORD'"
the issue is with the password it has 6 words like(alpha beta charlie) and whitespaces and I'm not allowed to change it
I also tried:
$PSQL_CLIENT "host=$servername user=$DB_USERNAME dbname=postgres password=/"$DB_PASSWORD"/"
everytime I'm trying to connect I'm seeing this error
psql: warning: extra command-line argument "password content" ignored
psql: warning: extra command-line argument "password content" ignored
psql: warning: extra command-line argument "password content" ignored
psql: warning: extra command-line argument "password content," ignored
I think something has to be changed at password=/"$DB_PASSWORD"/" not sure what exactly needs to be done to read the password properly. Any help would be appreciated
As the documentation says:
To write an empty value, or a value containing spaces, surround it with single quotes, for example keyword = 'a value'.
So your command should work well for passwords containing spaces. You will still have a problem if your password contains ' or \, because
Single quotes and backslashes within a value must be escaped with a backslash, i.e., \' and \\.
So you need to use
IFS='' escapedpwd=$(echo "$DB_PASSWORD" | sed -e "s/\([\']\)/\\\\\1/g")
$PSQL_CLIENT "host=$servername user=$DB_POSTGRES_USERNAME dbname=postgres password='$escapedpwd'"
After installing Emacs and Emacs Speaks Statistics (ESS) on a new machine, I am receiving the following error when I open an R buffer: ess-toggle-S-assign wrong number of arguments. I believe that this occurs due to the following section in my .emacs file where I reassign the assignment key from _ to ;, as shown below. Why does my .emacs file no longer work?
;; ESS hook additions. Note that the duplicate calls to `(ess-toggle-S-assign
;; nil)` are correct: the first call clears the default `ess-smart-S-assign`
;; assignment and the second line re-assigns it to the customized setting.
(add-hook 'ess-mode-hook
(lambda ()
(setq ess-smart-S-assign-key ";") ; reassign ' <- ' to ';'
(ess-toggle-S-assign nil) ; see above comment
(ess-toggle-S-assign nil))) ; see above comment
According to the ESS documentation https://ess.r-project.org/Manual/ess.html#New-features
Customization of ess-smart-S-assign-key has been reworked. You should now set the value before ESS is loaded.
So to reassign the assignment key as before, simply remove the existing lines of code from the ESS mode hook, and instead include the following lines in your .emacs file.
(setq ess-smart-S-assign-key ";")
(require 'ess-site)
I am a newbie to Lua. Currently getting the following error message:
invalid argument type for argument -model (should be the model checkpoint
to use for sampling)
Usage: [options] <model>
I am sure it is something pretty easy to solve, but cannot manage to find the solution.
The 'model' is a file lm_checkpoint_epoch50.00_2.7196.t7, which is in the directory
/home/ubuntu/xxx/nn/cv
I am running the program from the parent directory (/home/ubuntu/xxx/nn)
I have tried out the following options to run the program (from one directory above the one the model is saved):
th sample.lua - model lm_chelm_checkpoint_epoch50.00_2.5344.t7
th sample.lua lm_chelm_checkpoint_epoch50.00_2.5344.t7
th sample.lua /cv/lm_chelm_checkpoint_epoch50.00_2.5344.t7
th sample.lua - /cv/model lm_chelm_checkpoint_epoch50.00_2.5344.t7
Also, the program has a torch.CmdLine() object where :argument equals '/cv/lm_checkpoint_epoch50.00_2.7196.t7'. The program prints the parameters, so that you see the following output on the screen:
Options
<model> /cv/lm_checkpoint_epoch50.00_2.7196.t7
so it finds a value for argument 'model', which is picked up from the .lua file, not the parameter in the command line. This file is a valid mode.
Pretty lost, hope someone relates to this issue. Thanks.
found the issue - it was a bug as smhx suggested. I inadvertently changed the source code from:
require 'torch'
cmd = torch.CmdLine()
cmd:argument('-model','model checkpoint to use for sampling')
Note that there is no argument in the source code. To:
cmd:argument('-model','/cv/model lm_chelm_checkpoint_epoch50.00_2.5344.t7'
'model checkpoint to use for sampling')
So the argument must be passed through the command line, not the source code. With parameters, it is different - you can include them in the source code.
So if I change back the source code and run the following from the command line:
th sample.lua cv/lm_chelm_checkpoint_epoch50.00_2.5344.t7
it works.
I'm getting an error from Clang when using CLANG_WARN_DOCUMENTATION_COMMENTS on a doxygen block that contains following line
\post \ref something == somethingelse
The warning says "Empty paragraph passed to '\post' command"
Is this a valid use of \post?
If it is, does anyone know if there's a way to suppress this warning without disabling all documentation warnings?
Cheers.
I just installed macvim yesterday and I installed vim latex today.
One of the menu items is calling a broken function (TeX-Suite -> view).
When I click on the menu-time it makes this call:
:silent! call Tex_ViewLatex()
Question: Where can I find that function? Is there some way to figure out where it is defined?
Just for curiosity sake I removed the silent part and ran this:
:call Tex_ViewLatex()
Which produces:
Error detected while processing function Tex_ViewLaTeX:
line 34:
E121: Undefined variable: s:viewer
E116: Invalid arguments for function strlen(s:viewer)
E15: Invalid expression: strlen(s:viewer)
line 39:
E121: Undefined variable: appOpt
E15: Invalid expression: 'open '.appOpt.s:viewer.' $*.'.s:target
line 79:
E121: Undefined variable: execString
E116: Invalid arguments for function substitute(execString, '\V$*', mainfname, 'g'
)
E15: Invalid expression: substitute(execString, '\V$*', mainfname, 'g')
line 80:
E121: Undefined variable: execString
E116: Invalid arguments for function Tex_Debug
line 82:
E121: Undefined variable: execString
E15: Invalid expression: 'silent! !'.execString
Press ENTER or type command to continue
I suspect that if I could see the source function I could figure out what inputs are bad or what it is looking for.
Use the :verbose prefix command:
:verbose function Tex_ViewLaTeX
In the second line of output (just above the function's body) is the location of where the function was defined.
I installed gVim 7.2 on windows and latex-suite, and miktex too
I tried what you said, after compile and view, I can view the dvi files
The error message seemed like to indicate it's the view's problem
The document for latex-suite said the viewer for Macintosh is not set, maybe it's where the problem lies
I think you can try to set a few variables in your .vimrc file, to set up the proper viewing app for PDF files
And the source code for Tex_ViewLaTeX is here:
http://www.tedpavlic.com/research_related/tpavlic_masters_thesis/compiler.vim
By the way, I also installed MacVim on my Macbook Pro, however I never used vim for LaTeXing, because I find TextMate and its latex bundle is much superior than MacVim, you'll definately like it
One way to search would be to do a grep or vimgrep on directory tree where you thought the source file was located. Search for 'function Tex_ViewLatex' or 'function! Tex_ViewLatex'.
I believe in the usual install it would be in a .../ftplugin/latex-suite/compiler.vim file, as part of the latex-suite plugin. There are a couple ftplugin directories, so make sure you get right one (one is in tree of main vim install and other may be off your home .vim directory.
It seems there is a bug with the Tex_ViewLatex function on OS X. Check here for some info:
http://comments.gmane.org/gmane.comp.editors.vim.latex.devel/775
Put this in your .vimrc, solved the problem for me.
let g:Tex_ViewRule_pdf = 'open -a Preview.app'