conditional-statements

Docker-compose, conditional statements? (e.g. add volume only if condition)

眉间皱痕 提交于 2020-12-01 08:03:13
问题 I want to add a volume to my service, but only if the final user gave a folder for it. Otherwise, no volume should be mounted, for the already-prepared image has valid data in a default folder. That is, I want to do something like (pseudocode): services: my_awesome_service: volumes: if ${VARIABLE} => ${VARIABLE}:/app/folder Are such conditional statements definable in a docker-compose file? The only way I see to make this possible is to first define a base docker-compose file, which does not

How to compare a char?

北城以北 提交于 2020-11-26 06:41:08
问题 I am learning c. I have a question. Why doesn't my program work? #include<stdio.h> #include<conio.h> #include<stdlib.h> char cmd; void exec() { if (cmd == "e") { printf("%c", cmd); // exit(0); } else { printf("Illegal Arg"); } } void input() { scanf("%c", &cmd); exec(); } int main() { input(); return 0; } I insert a "e" but it says illegal arg. cmd is not equal to "e". Why? I set cmd with scanf to "e". 回答1: First of, in C single quotes are char literals, and double quotes are string literals.