How to make `adb shell settings put` keep the part after `$` in the following?

```bash
adb shell settings put secure enabled_notification_listeners 'com.termux.api/com.termux.api.apis.NotificationListAPI$NotificationService'
adb shell settings get secure enabled_notification_listeners
```
```
com.termux.api/com.termux.api.apis.NotificationListAPI
```

Tested on LineageOS 23.0 Virtual Machine Manager virtual machine from Debian 13 GNOME.
2/2
Jul 18, 2:53pm

The issue you're encountering is that the $ character in the value is being interpreted as a shell variable or causing the string to be truncated. In shell environments (including adb shell), the $ character has special meaning (e.g., for variables like $HOME or $USER). To pass the literal string com.termux.api/com.termux.api.apis.NotificationListAPI$NotificationService without interpretation, you need to escape the $ character or quote the string properly.


Solution 1: Escape the $ Character

Escape the $ with a backslash (\):

bash
adb shell settings put secure enabled_notification_listeners 'com.termux.api/com.termux.api.apis.NotificationListAPI\$NotificationService'

Solution 2: Use Double Quotes

Double quotes in shell allow most special characters (including $) to be treated literally, except for $, backticks (`), and backslashes (\). However, if you want to ensure the \$ is treated as a literal, you can still escape it inside double quotes:

bash
adb shell settings put secure enabled_notification_listeners "com.termux.api/com.termux.api.apis.NotificationListAPI\$NotificationService"

Solution 3: Single Quotes (Recommended)

Single quotes in shell treat all characters literally, including $. This is the most reliable way:

bash
adb shell settings put secure enabled_notification_listeners 'com.termux.api/com.termux.api.apis.NotificationListAPI$NotificationService'

If this didn't work for you, it might be due to how the settings command itself processes the input. In that case, try escaping the $ as shown in Solution 1 or 2.


Solution 4: Use set with Escaped $

If the above fails, try using set to explicitly pass the value:

bash
adb shell set secure enabled_notification_listeners "com.termux.api/com.termux.api.apis.NotificationListAPI\$NotificationService"

Verification

After running the put command, verify with:

bash
adb shell settings get secure enabled_notification_listeners

The output should now include the full string:

text
com.termux.api/com.termux.api.apis.NotificationListAPI$NotificationService

Why This Happens

  • In shell, $ is used for variable expansion (e.g., $USER). If not escaped or quoted, the shell may interpret $NotificationService as a variable name.
  • Single quotes (') are the safest for literal strings, as they prevent all shell interpretations.
Jul 18, 2:54pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more