# checking if installation script is launch in a terminal

**URL:** https://discourse.cmake.org/t/checking-if-installation-script-is-launch-in-a-terminal/8134
**Category:** Usage
**Tags:** os:linux, os:windows
**Created:** [May 16, 2023, 12:19pm UTC](https://discourse.cmake.org/t/checking-if-installation-script-is-launch-in-a-terminal/8134 "2023-05-16T12:19:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [May 16, 2023, 12:19pm UTC](https://discourse.cmake.org/t/checking-if-installation-script-is-launch-in-a-terminal/8134/1 "2023-05-16T12:19:30Z")

</div>

Hi, on installing a target, I launch a cmake script (set with `install(SCRIPT...`) which, in turn launch shell scripts (with `execute_process`) in order to prompt the user for some “last minute” input.  
Yet if my installation command is launched in a non-interactive way, I’d like to bypass this prompt and resort to default values.  
How can I do?

more precisely, the normal situation would be something like that in a terminal:

```auto
make install
<prompt user>
<finishing install>

```

But if I’m not in a terminal (for instance, launching the installation from a daemon at a given hour), I would like to replace `<prompt user>` by `<set default values>`

Visibly, I cannot do that from the prompting shell which is already considered as non interactive, as it is launched from cmake script.

A basic workaround would be to pass an additionnal option at configuration time to ask for an install with or without prompt but an automated solution would be better for me.

Thanks, regards  
A.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 16, 2023, 2:35pm UTC](https://discourse.cmake.org/t/checking-if-installation-script-is-launch-in-a-terminal/8134/2 "2023-05-16T14:35:18Z")

</div>

I think CMake could probably learn to pass `stdin` down to `execute_process` as-is, but this would be a new flag/feature (not sure if the `install` would use it by default either). That would let your prompt script do the normal `isatty` checks on `stdin`. You may want to ask an environment variable before falling back to a default too as well (not sure if you’d prefer the envvar suppressing the manual request or to act as a fallback only if the prompt can’t be asked).

---

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [May 16, 2023, 2:56pm UTC](https://discourse.cmake.org/t/checking-if-installation-script-is-launch-in-a-terminal/8134/3 "2023-05-16T14:56:42Z")

</div>

Is there a way to do this check in cmake? Yet I’m unsure if the pertinence of the output.  
For instance, when checking `$- == *i*` in my prompting script, it tells me that its a non-interactive shell (which is kind of logic, as it is called from inside a cmake `execute_process` that, I think, is forking a sub-shell).  
But maybe that isatty will not give the same info (are we in an interactive terminal instead of is it an interactive shell)?

Besides, I would need an equivalent solution for windows system also.

Thanks

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 17, 2023, 11:44am UTC](https://discourse.cmake.org/t/checking-if-installation-script-is-launch-in-a-terminal/8134/4 "2023-05-17T11:44:49Z")

</div>

> [@adaldev](#):
>
> Is there a way to do this check in cmake?

I don’t think so, no.
